q16.sql 489 B

12345678910111213141516171819202122232425262728293031323334
  1. --!syntax_pg
  2. --TPC-H Q16
  3. select
  4. p_brand,
  5. p_type,
  6. p_size,
  7. count(distinct ps_suppkey) as supplier_cnt
  8. from
  9. plato."partsupp",
  10. plato."part"
  11. where
  12. p_partkey = ps_partkey
  13. and p_brand <> 'Brand#45'
  14. and p_type not like 'MEDIUM POLISHED%'
  15. and p_size in (49, 14, 23, 45, 19, 3, 36, 9)
  16. and ps_suppkey not in (
  17. select
  18. s_suppkey
  19. from
  20. plato."supplier"
  21. where
  22. s_comment like '%Customer%Complaints%'
  23. )
  24. group by
  25. p_brand,
  26. p_type,
  27. p_size
  28. order by
  29. supplier_cnt desc,
  30. p_brand,
  31. p_type,
  32. p_size;