blob: 960a8e6b033ebbe97a290057d94231c4b2dc5afe [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)
ramangrover29669d8f62013-02-11 06:03:32 +000019 primary key oid on group1;
vinayakb38b7ca42012-03-05 05:44:15 +000020
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) }