q13.sql 348 B

12345678910111213141516171819202122232425
  1. --!syntax_pg
  2. --TPC-H Q13
  3. select
  4. c_count, count(*) as custdist
  5. from (
  6. select
  7. c_custkey,
  8. count(o_orderkey)
  9. from
  10. plato."customer"
  11. left outer join
  12. plato."orders"
  13. on
  14. c_custkey = o_custkey
  15. and o_comment not like '%special%requests%'
  16. group by
  17. c_custkey
  18. )as c_orders (c_custkey, c_count)
  19. group by
  20. c_count
  21. order by
  22. custdist desc,
  23. c_count desc;