Skip to content

Commit

Permalink
Fix q17
Browse files Browse the repository at this point in the history
  • Loading branch information
resetius committed Oct 14, 2023
1 parent 306a5ee commit fa0ca3f
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions ydb/library/benchmarks/queries/tpch/yql/q17.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,41 @@
-- TPC TPC-H Parameter Substitution (Version 2.17.2 build 0)
-- using 1680793381 as a seed to the RNG

$p = select p_partkey from {{part}}
where
p_brand = 'Brand#35'
and p_container = 'LG DRUM'
;

$threshold = (
select
0.2 * avg(l_quantity) as threshold,
l.l_partkey as l_partkey
from
{{lineitem}} as l
join
{{part}} as p
on
left semi join
$p as p
on
p.p_partkey = l.l_partkey
where
p.p_brand = 'Brand#35'
and p.p_container = 'LG DRUM'
group by
l.l_partkey
);

$l = select l.l_partkey as l_partkey, l.l_quantity as l_quantity, l.l_extendedprice as l_extendedprice
from
{{lineitem}} as l
join
$p as p
on
p.p_partkey = l.l_partkey;

select
sum(l.l_extendedprice) / 7.0 as avg_yearly
from
{{lineitem}} as l
$l as l
join
$threshold as t
on
on
t.l_partkey = l.l_partkey
where
l.l_quantity < t.threshold;
Expand Down

0 comments on commit fa0ca3f

Please sign in to comment.