blob: 35d1a99ab31fb423666fff7ea0749c6f5d2952a7 [file] [log] [blame]
Ian Maxon857dc132015-09-25 17:13:19 -07001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
Till Westmann4c4ca1f2013-07-26 17:12:02 -070019use dataverse tpch;
20
21for $l in dataset('LineItem')
22for $o in dataset('Orders')
23where $o.o_orderkey = $l.l_orderkey
24 and $l.l_commitdate < $l.l_receiptdate
25 and $l.l_shipdate < $l.l_commitdate
26 and $l.l_receiptdate >= '1994-01-01'
27 and $l.l_receiptdate < '1995-01-01'
28 and ($l.l_shipmode = 'MAIL' or $l.l_shipmode = 'SHIP')
29group by $l_shipmode := $l.l_shipmode with $o
30order by $l_shipmode
31return {
32 "l_shipmode": $l_shipmode,
33 "high_line_count": sum(
34 for $i in $o
35 return
36 switch-case($i.o_orderpriority ='1-URGENT' or $i.o_orderpriority ='2-HIGH',
37 true, 1, false, 0)
38 ),
39 "low_line_count": sum(
40 for $i in $o
41 return switch-case($i.o_orderpriority ='1-URGENT' or $i.o_orderpriority ='2-HIGH',
42 true, 0, false, 1)
43 )
44}
45