query67.sql 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. -- start query 1 in stream 0 using template query67.tpl and seed 1819994127
  2. select *
  3. from (select i_category
  4. ,i_class
  5. ,i_brand
  6. ,i_product_name
  7. ,d_year
  8. ,d_qoy
  9. ,d_moy
  10. ,s_store_id
  11. ,sumsales
  12. ,rank() over (partition by i_category order by sumsales desc) rk
  13. from (select i_category
  14. ,i_class
  15. ,i_brand
  16. ,i_product_name
  17. ,d_year
  18. ,d_qoy
  19. ,d_moy
  20. ,s_store_id
  21. ,sum(coalesce(ss_sales_price*ss_quantity,0)) sumsales
  22. from store_sales
  23. ,date_dim
  24. ,store
  25. ,item
  26. where ss_sold_date_sk=d_date_sk
  27. and ss_item_sk=i_item_sk
  28. and ss_store_sk = s_store_sk
  29. and d_month_seq between 1185 and 1185+11
  30. group by rollup(i_category, i_class, i_brand, i_product_name, d_year, d_qoy, d_moy,s_store_id))dw1) dw2
  31. where rk <= 100
  32. order by i_category
  33. ,i_class
  34. ,i_brand
  35. ,i_product_name
  36. ,d_year
  37. ,d_qoy
  38. ,d_moy
  39. ,s_store_id
  40. ,sumsales
  41. ,rk
  42. limit 100;
  43. -- end query 1 in stream 0 using template query67.tpl