q14.sql 605 B

123456789101112131415161718192021
  1. -- TPC-H/TPC-R Promotion Effect Query (Q14)
  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-08-01");
  5. select
  6. 100.00 * sum(case
  7. when StartsWith(p.p_type, 'PROMO')
  8. then l.l_extendedprice * (1 - l.l_discount)
  9. else 0
  10. end) / sum(l.l_extendedprice * (1 - l.l_discount)) as promo_revenue
  11. from
  12. plato.lineitem as l
  13. join
  14. plato.part as p
  15. on
  16. l.l_partkey = p.p_partkey
  17. where
  18. cast(l.l_shipdate as timestamp) >= $border
  19. and cast(l.l_shipdate as timestamp) < ($border + Interval("P31D"));