q10.sql 566 B

123456789101112131415161718192021222324252627282930313233343536
  1. --!syntax_pg
  2. --TPC-H Q10
  3. select
  4. c_custkey,
  5. c_name,
  6. sum(l_extendedprice * (1::numeric - l_discount)) as revenue,
  7. c_acctbal,
  8. n_name,
  9. c_address,
  10. c_phone,
  11. c_comment
  12. from
  13. plato."customer",
  14. plato."orders",
  15. plato."lineitem",
  16. plato."nation"
  17. where
  18. c_custkey = o_custkey
  19. and l_orderkey = o_orderkey
  20. and o_orderdate >= date '1993-10-01'
  21. and o_orderdate < date '1993-10-01' + interval '3' month
  22. and l_returnflag = 'R'
  23. and c_nationkey = n_nationkey
  24. group by
  25. c_custkey,
  26. c_name,
  27. c_acctbal,
  28. c_phone,
  29. n_name,
  30. c_address,
  31. c_comment
  32. order by
  33. revenue desc
  34. limit 20;