q61.sql 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. --!syntax_pg
  2. --TPC-DS Q61
  3. -- start query 1 in stream 0 using template ../query_templates/query61.tpl
  4. select promotions,total,cast(promotions as decimal(15,4))/cast(total as decimal(15,4))*100::numeric
  5. from
  6. (select sum(ss_ext_sales_price) promotions
  7. from plato.store_sales
  8. ,plato.store
  9. ,plato.promotion
  10. ,plato.date_dim
  11. ,plato.customer
  12. ,plato.customer_address
  13. ,plato.item
  14. where ss_sold_date_sk = d_date_sk
  15. and ss_store_sk = s_store_sk
  16. and ss_promo_sk = p_promo_sk
  17. and ss_customer_sk= c_customer_sk
  18. and ca_address_sk = c_current_addr_sk
  19. and ss_item_sk = i_item_sk
  20. and ca_gmt_offset = -7::numeric
  21. and i_category = 'Books'
  22. and (p_channel_dmail = 'Y' or p_channel_email = 'Y' or p_channel_tv = 'Y')
  23. and s_gmt_offset = -7::numeric
  24. and d_year = 1999
  25. and d_moy = 11) promotional_sales,
  26. (select sum(ss_ext_sales_price) total
  27. from plato.store_sales
  28. ,plato.store
  29. ,plato.date_dim
  30. ,plato.customer
  31. ,plato.customer_address
  32. ,plato.item
  33. where ss_sold_date_sk = d_date_sk
  34. and ss_store_sk = s_store_sk
  35. and ss_customer_sk= c_customer_sk
  36. and ca_address_sk = c_current_addr_sk
  37. and ss_item_sk = i_item_sk
  38. and ca_gmt_offset = -7::numeric
  39. and i_category = 'Books'
  40. and s_gmt_offset = -7::numeric
  41. and d_year = 1999
  42. and d_moy = 11) all_sales
  43. order by promotions, total
  44. limit 100;
  45. -- end query 1 in stream 0 using template ../query_templates/query61.tpl