q28.sql 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. --!syntax_pg
  2. --TPC-DS Q28
  3. -- start query 1 in stream 0 using template ../query_templates/query28.tpl
  4. select *
  5. from (select avg(ss_list_price) B1_LP
  6. ,count(ss_list_price) B1_CNT
  7. ,count(distinct ss_list_price) B1_CNTD
  8. from plato.store_sales
  9. where ss_quantity between 0 and 5
  10. and (ss_list_price between 11::numeric and (11+10)::numeric
  11. or ss_coupon_amt between 460::numeric and (460+1000)::numeric
  12. or ss_wholesale_cost between 14::numeric and (14+20)::numeric)) B1,
  13. (select avg(ss_list_price) B2_LP
  14. ,count(ss_list_price) B2_CNT
  15. ,count(distinct ss_list_price) B2_CNTD
  16. from plato.store_sales
  17. where ss_quantity between 6 and 10
  18. and (ss_list_price between 91::numeric and (91+10)::numeric
  19. or ss_coupon_amt between 1430::numeric and (1430+1000)::numeric
  20. or ss_wholesale_cost between 32::numeric and (32+20)::numeric)) B2,
  21. (select avg(ss_list_price) B3_LP
  22. ,count(ss_list_price) B3_CNT
  23. ,count(distinct ss_list_price) B3_CNTD
  24. from plato.store_sales
  25. where ss_quantity between 11 and 15
  26. and (ss_list_price between 66::numeric and (66+10)::numeric
  27. or ss_coupon_amt between 920::numeric and (920+1000)::numeric
  28. or ss_wholesale_cost between 4::numeric and (4+20)::numeric)) B3,
  29. (select avg(ss_list_price) B4_LP
  30. ,count(ss_list_price) B4_CNT
  31. ,count(distinct ss_list_price) B4_CNTD
  32. from plato.store_sales
  33. where ss_quantity between 16 and 20
  34. and (ss_list_price between 142::numeric and (142+10)::numeric
  35. or ss_coupon_amt between 3054::numeric and (3054+1000)::numeric
  36. or ss_wholesale_cost between 80::numeric and (80+20)::numeric)) B4,
  37. (select avg(ss_list_price) B5_LP
  38. ,count(ss_list_price) B5_CNT
  39. ,count(distinct ss_list_price) B5_CNTD
  40. from plato.store_sales
  41. where ss_quantity between 21 and 25
  42. and (ss_list_price between 135::numeric and (135+10)::numeric
  43. or ss_coupon_amt between 14180::numeric and (14180+1000)::numeric
  44. or ss_wholesale_cost between 38::numeric and (38+20)::numeric)) B5,
  45. (select avg(ss_list_price) B6_LP
  46. ,count(ss_list_price) B6_CNT
  47. ,count(distinct ss_list_price) B6_CNTD
  48. from plato.store_sales
  49. where ss_quantity between 26 and 30
  50. and (ss_list_price between 28::numeric and (28+10)::numeric
  51. or ss_coupon_amt between 2513::numeric and (2513+1000)::numeric
  52. or ss_wholesale_cost between 42::numeric and (42+20)::numeric)) B6
  53. limit 100;
  54. -- end query 1 in stream 0 using template ../query_templates/query28.tpl