q16.sql 956 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. -- TPC-H/TPC-R Parts/Supplier Relationship Query (Q16)
  2. -- TPC TPC-H Parameter Substitution (Version 2.17.2 build 0)
  3. -- using 1680793381 as a seed to the RNG
  4. $join = (
  5. select
  6. ps.ps_suppkey as ps_suppkey,
  7. ps.ps_partkey as ps_partkey
  8. from
  9. plato.partsupp as ps
  10. left join
  11. plato.supplier as w
  12. on
  13. w.s_suppkey = ps.ps_suppkey
  14. where not (s_comment like "%Customer%Complaints%")
  15. );
  16. select
  17. p.p_brand as p_brand,
  18. p.p_type as p_type,
  19. p.p_size as p_size,
  20. count(distinct j.ps_suppkey) as supplier_cnt
  21. from
  22. $join as j
  23. join
  24. plato.part as p
  25. on
  26. p.p_partkey = j.ps_partkey
  27. where
  28. p.p_brand <> 'Brand#33'
  29. and (not StartsWith(p.p_type, 'PROMO POLISHED'))
  30. and (p.p_size = 20 or p.p_size = 27 or p.p_size = 11 or p.p_size = 45 or p.p_size = 40 or p.p_size = 41 or p.p_size = 34 or p.p_size = 36)
  31. group by
  32. p.p_brand,
  33. p.p_type,
  34. p.p_size
  35. order by
  36. supplier_cnt desc,
  37. p_brand,
  38. p_type,
  39. p_size
  40. ;