q05.sql 541 B

12345678910111213141516171819202122232425262728
  1. --!syntax_pg
  2. --TPC-H Q5
  3. select
  4. n_name,
  5. sum(l_extendedprice * (1::numeric - l_discount)) as revenue
  6. from
  7. plato."customer",
  8. plato."orders",
  9. plato."lineitem",
  10. plato."supplier",
  11. plato."nation",
  12. plato."region"
  13. where
  14. c_custkey = o_custkey
  15. and l_orderkey = o_orderkey
  16. and l_suppkey = s_suppkey
  17. and c_nationkey = s_nationkey
  18. and s_nationkey = n_nationkey
  19. and n_regionkey = r_regionkey
  20. and r_name = 'ASIA'
  21. and o_orderdate >= date '1994-01-01'
  22. and o_orderdate < date '1994-01-01' + interval '1' year
  23. group by
  24. n_name
  25. order by
  26. revenue desc;