q12.sql 955 B

12345678910111213141516171819202122232425262728293031323334353637
  1. --!syntax_pg
  2. --TPC-DS Q12
  3. -- start query 1 in stream 0 using template ../query_templates/query12.tpl
  4. select i_item_id
  5. ,i_item_desc
  6. ,i_category
  7. ,i_class
  8. ,i_current_price
  9. ,sum(ws_ext_sales_price) as itemrevenue
  10. ,sum(ws_ext_sales_price)*100::numeric/sum(sum(ws_ext_sales_price)) over
  11. (partition by i_class) as revenueratio
  12. from
  13. plato.web_sales
  14. ,plato.item
  15. ,plato.date_dim
  16. where
  17. ws_item_sk = i_item_sk
  18. and i_category in ('Jewelry', 'Sports', 'Books')
  19. and ws_sold_date_sk = d_date_sk
  20. and d_date between cast('2001-01-12' as date)
  21. and (cast('2001-01-12' as date) + interval '30' day)::date
  22. group by
  23. i_item_id
  24. ,i_item_desc
  25. ,i_category
  26. ,i_class
  27. ,i_current_price
  28. order by
  29. i_category
  30. ,i_class
  31. ,i_item_id
  32. ,i_item_desc
  33. ,revenueratio
  34. limit 100;
  35. -- end query 1 in stream 0 using template ../query_templates/query12.tpl