blob: 6603c8e8cc09637692d9be4c24c1b444a3066b17 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
use dataverse tpch;
for $l in dataset('LineItem')
for $p in dataset('Part')
where $l.l_partkey = $p.p_partkey
and $l.l_shipdate >= '1995-09-01'
and $l.l_shipdate < '1995-10-01'
let $lp := {
"l_extendedprice": $l.l_extendedprice,
"l_discount": $l.l_discount,
"p_type": $p.p_type
}
group by $t:=1 with $lp
return 100.00 * sum(
for $i in $lp
return switch-case(like($i.p_type, 'PROMO%'),
true, $i.l_extendedprice*(1-$i.l_discount),
false, 0.0)
) / sum(for $i in $lp return $i.l_extendedprice * (1 - $i.l_discount)
)