query20.sql 804 B

123456789101112131415161718192021222324252627
  1. select i_item_desc
  2. ,i_category
  3. ,i_class
  4. ,i_current_price
  5. ,i_item_id
  6. ,sum(cs_ext_sales_price) as itemrevenue
  7. ,sum(cs_ext_sales_price)*100/sum(sum(cs_ext_sales_price)) over
  8. (partition by i_class) as revenueratio
  9. from catalog_sales
  10. ,item
  11. ,date_dim
  12. where catalog_sales.cs_item_sk = item.i_item_sk
  13. and i_category in ('Jewelry', 'Sports', 'Books')
  14. and catalog_sales.cs_sold_date_sk = date_dim.d_date_sk
  15. and d_date between '2001-01-12' and '2001-02-11'
  16. and cs_sold_date between '2001-01-12' and '2001-02-11'
  17. group by i_item_id
  18. ,i_item_desc
  19. ,i_category
  20. ,i_class
  21. ,i_current_price
  22. order by i_category
  23. ,i_class
  24. ,i_item_id
  25. ,i_item_desc
  26. ,revenueratio
  27. limit 100;