vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1 | drop dataverse orders-aggreg if exists; |
| 2 | |
| 3 | create dataverse orders-aggreg; |
| 4 | |
| 5 | use dataverse orders-aggreg; |
| 6 | |
| 7 | create type OrderType as closed { |
| 8 | oid: int32, |
| 9 | cid: int32, |
| 10 | orderstatus: string, |
| 11 | orderpriority: string, |
| 12 | clerk: string, |
| 13 | total: float |
| 14 | } |
| 15 | |
| 16 | create nodegroup group1 if not exists on nc1, nc2; |
| 17 | |
| 18 | create dataset Orders(OrderType) |
| 19 | partitioned by key oid on group1; |
| 20 | |
| 21 | write output to nc1:"/tmp/orders-aggreg.adm"; |
| 22 | |
| 23 | for $o in dataset('Orders') |
| 24 | group by $cid := $o.cid with $o |
| 25 | return { "cid": $cid , "ordpercust": count($o), |
| 26 | "totalcust": sum(for $i in $o return $i.total), |
| 27 | "avgcust": avg(for $i in $o return $i.total) } |