blob: e6007e7580f42c904961b2dc79f4e0bcbd2acee5 [file] [log] [blame]
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)
)