tpch_query10.sql 474 B

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