q11.sql 576 B

1234567891011121314151617181920212223242526272829303132
  1. --!syntax_pg
  2. --TPC-H Q11
  3. -- ignore runonopt plan diff
  4. select
  5. ps_partkey,
  6. sum(ps_supplycost * ps_availqty::numeric) as value
  7. from
  8. plato."partsupp",
  9. plato."supplier",
  10. plato."nation"
  11. where
  12. ps_suppkey = s_suppkey
  13. and s_nationkey = n_nationkey
  14. and n_name = 'GERMANY'
  15. group by
  16. ps_partkey having
  17. sum(ps_supplycost * ps_availqty::numeric) > (
  18. select
  19. sum(ps_supplycost * ps_availqty::numeric) * 0.0001::numeric
  20. from
  21. plato."partsupp",
  22. plato."supplier",
  23. plato."nation"
  24. where
  25. ps_suppkey = s_suppkey
  26. and s_nationkey = n_nationkey
  27. and n_name = 'GERMANY'
  28. )
  29. order by
  30. value desc;