q19.sql 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. -- TPC-H/TPC-R Discounted Revenue Query (Q19)
  2. -- TPC TPC-H Parameter Substitution (Version 2.17.2 build 0)
  3. -- using 1680793381 as a seed to the RNG
  4. select
  5. sum(l.l_extendedprice* (1 - l.l_discount)) as revenue
  6. from
  7. plato.lineitem as l
  8. join
  9. plato.part as p
  10. on
  11. p.p_partkey = l.l_partkey
  12. where
  13. (
  14. p.p_brand = 'Brand#23'
  15. and (p.p_container = 'SM CASE' or p.p_container = 'SM BOX' or p.p_container = 'SM PACK' or p.p_container = 'SM PKG')
  16. and l.l_quantity >= 7 and l.l_quantity <= 7 + 10
  17. and p.p_size between 1 and 5
  18. and (l.l_shipmode = 'AIR' or l.l_shipmode = 'AIR REG')
  19. and l.l_shipinstruct = 'DELIVER IN PERSON'
  20. )
  21. or
  22. (
  23. p.p_brand = 'Brand#15'
  24. and (p.p_container = 'MED BAG' or p.p_container = 'MED BOX' or p.p_container = 'MED PKG' or p.p_container = 'MED PACK')
  25. and l.l_quantity >= 17 and l.l_quantity <= 17 + 10
  26. and p.p_size between 1 and 10
  27. and (l.l_shipmode = 'AIR' or l.l_shipmode = 'AIR REG')
  28. and l.l_shipinstruct = 'DELIVER IN PERSON'
  29. )
  30. or
  31. (
  32. p.p_brand = 'Brand#44'
  33. and (p.p_container = 'LG CASE' or p.p_container = 'LG BOX' or p.p_container = 'LG PACK' or p.p_container = 'LG PKG')
  34. and l.l_quantity >= 25 and l.l_quantity <= 25 + 10
  35. and p.p_size between 1 and 15
  36. and (l.l_shipmode = 'AIR' or l.l_shipmode = 'AIR REG')
  37. and l.l_shipinstruct = 'DELIVER IN PERSON'
  38. );