q02.sql 745 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. --!syntax_pg
  2. --ignore runonopt plan diff
  3. --TPC-H Q2
  4. select
  5. s_acctbal,
  6. s_name,
  7. n_name,
  8. p_partkey,
  9. p_mfgr,
  10. s_address,
  11. s_phone,
  12. s_comment
  13. from
  14. plato."part",
  15. plato."supplier",
  16. plato."partsupp",
  17. plato."nation",
  18. plato."region"
  19. where
  20. p_partkey = ps_partkey
  21. and s_suppkey = ps_suppkey
  22. and p_size = 15
  23. and p_type like '%BRASS'
  24. and s_nationkey = n_nationkey
  25. and n_regionkey = r_regionkey
  26. and r_name = 'EUROPE'
  27. and ps_supplycost = (
  28. select
  29. min(ps_supplycost)
  30. from
  31. plato."partsupp",
  32. plato."supplier",
  33. plato."nation",
  34. plato."region"
  35. where
  36. p_partkey = ps_partkey
  37. and s_suppkey = ps_suppkey
  38. and s_nationkey = n_nationkey
  39. and n_regionkey = r_regionkey
  40. and r_name = 'EUROPE'
  41. )
  42. order by
  43. s_acctbal desc,
  44. n_name,
  45. s_name,
  46. p_partkey
  47. limit 100;