q04.sql 386 B

1234567891011121314151617181920212223242526
  1. --!syntax_pg
  2. --ignore runonopt plan diff
  3. --TPC-H Q4
  4. select
  5. o_orderpriority,
  6. count(*) as order_count
  7. from
  8. plato."orders"
  9. where
  10. o_orderdate >= date '1993-07-01'
  11. and o_orderdate < date '1993-07-01' + interval '3' month
  12. and exists (
  13. select
  14. *
  15. from
  16. plato."lineitem"
  17. where
  18. l_orderkey = o_orderkey
  19. and l_commitdate < l_receiptdate
  20. )
  21. group by
  22. o_orderpriority
  23. order by
  24. o_orderpriority;