query61.sql 1.3 KB

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