blob: c2f96f6dc7686e04116bd5bf5902c60a1a35d4b9 [file] [log] [blame]
vinayakb38b7ca42012-03-05 05:44:15 +00001drop dataverse orders-aggreg if exists;
2
3create dataverse orders-aggreg;
4
5use dataverse orders-aggreg;
6
7create type OrderType as closed {
8 oid: int32,
9 cid: int32,
10 orderstatus: string,
11 orderpriority: string,
12 clerk: string,
13 total: float
14}
15
16create nodegroup group1 if not exists on nc1, nc2;
17
18create dataset Orders(OrderType)
19 partitioned by key oid on group1;
20
21write output to nc1:"/tmp/orders-aggreg.adm";
22
23for $o in dataset('Orders')
24group by $cid := $o.cid with $o
25return { "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) }