[rules-users] Disting and group by

vijrams mailrvijay at gmail.com
Fri Aug 13 00:55:04 EDT 2010


Thanks Wolfgang and Edson for your help

i was able to make it work

below is my rule

declare ReportForDate
     custNo : String 
     chargeDate : Date
end

rule "insert report dates"
    salience 10
    dialect "mvel"
when
    $lineItems : Customer (person != null, $custNo : person.ID, $ChargeDate
: lineItemDate)
    not( ReportForDate( custNo == $custNo, chargeDate == $ChargeDate ) )
then
    with( $r = new ReportForDate() ) {
        custNo = $custNo,
        chargeDate = $ChargeDate
    }
    insert( $r );
end

rule "customers that purchased more than 100 on a given date"
when
	$CustDateInfo : ReportForDate($custNo : custNo, $ChargeDate : chargeDate)
	$dayTotal : Number(doubleValue > 100) from accumulate( Customer ( person.ID
== $custNo, lineItemDate == $ChargeDate
    		, $amt : amount ) 
    		, sum( $amt ) )
then
    System.out.println("********* 	customer " + $custNo +" billed over 100 
per day");	
end

-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Distinct-and-group-by-tp1076615p1126685.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list