q4.sql 790 B

1234567891011121314151617181920212223242526272829
  1. -- TPC-H/TPC-R Order Priority Checking Query (Q4)
  2. -- TPC TPC-H Parameter Substitution (Version 2.17.2 build 0)
  3. -- using 1680793381 as a seed to the RNG
  4. $border = Date("1994-03-01");
  5. $join = (select
  6. o.o_orderpriority as o_orderpriority,
  7. o.o_orderdate as o_orderdate,
  8. l.l_commitdate as l_commitdate,
  9. l.l_receiptdate as l_receiptdate
  10. from
  11. plato.orders as o
  12. join any plato.lineitem as l
  13. on o.o_orderkey = l.l_orderkey);
  14. select
  15. o_orderpriority,
  16. count(*) as order_count
  17. from $join
  18. where
  19. CAST(o_orderdate AS Timestamp) >= $border
  20. and CAST(o_orderdate AS Timestamp) < DateTime::MakeDate(DateTime::ShiftMonths($border, 3))
  21. and l_commitdate < l_receiptdate
  22. group by
  23. o_orderpriority
  24. order by
  25. o_orderpriority;