q19.sql 1012 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. --!syntax_pg
  2. --TPC-H Q19
  3. select
  4. sum(l_extendedprice * (1::numeric - l_discount) ) as revenue
  5. from
  6. plato."lineitem",
  7. plato."part"
  8. where
  9. (
  10. p_partkey = l_partkey
  11. and p_brand = 'Brand#12'
  12. and p_container in ( 'SM CASE', 'SM BOX', 'SM PACK', 'SM PKG')
  13. and l_quantity >= 1::numeric and l_quantity <= (1 + 10)::numeric
  14. and p_size between 1 and 5
  15. and l_shipmode in ('AIR', 'AIR REG')
  16. and l_shipinstruct = 'DELIVER IN PERSON'
  17. )
  18. or
  19. (
  20. p_partkey = l_partkey
  21. and p_brand = 'Brand#23'
  22. and p_container in ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK')
  23. and l_quantity >= 10::numeric and l_quantity <= (10 + 10)::numeric
  24. and p_size between 1 and 10
  25. and l_shipmode in ('AIR', 'AIR REG')
  26. and l_shipinstruct = 'DELIVER IN PERSON'
  27. )
  28. or
  29. (
  30. p_partkey = l_partkey
  31. and p_brand = 'Brand#34'
  32. and p_container in ( 'LG CASE', 'LG BOX', 'LG PACK', 'LG PKG')
  33. and l_quantity >= 20::numeric and l_quantity <= (20 + 10)::numeric
  34. and p_size between 1 and 15
  35. and l_shipmode in ('AIR', 'AIR REG')
  36. and l_shipinstruct = 'DELIVER IN PERSON'
  37. );