q71.sql 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --!syntax_pg
  2. --TPC-DS Q71
  3. -- start query 1 in stream 0 using template ../query_templates/query71.tpl
  4. select i_brand_id brand_id, i_brand brand,t_hour,t_minute,
  5. sum(ext_price) ext_price
  6. from plato.item, (select ws_ext_sales_price as ext_price,
  7. ws_sold_date_sk as sold_date_sk,
  8. ws_item_sk as sold_item_sk,
  9. ws_sold_time_sk as time_sk
  10. from plato.web_sales,plato.date_dim
  11. where d_date_sk = ws_sold_date_sk
  12. and d_moy=12
  13. and d_year=2000
  14. union all
  15. select cs_ext_sales_price as ext_price,
  16. cs_sold_date_sk as sold_date_sk,
  17. cs_item_sk as sold_item_sk,
  18. cs_sold_time_sk as time_sk
  19. from plato.catalog_sales,plato.date_dim
  20. where d_date_sk = cs_sold_date_sk
  21. and d_moy=12
  22. and d_year=2000
  23. union all
  24. select ss_ext_sales_price as ext_price,
  25. ss_sold_date_sk as sold_date_sk,
  26. ss_item_sk as sold_item_sk,
  27. ss_sold_time_sk as time_sk
  28. from plato.store_sales,plato.date_dim
  29. where d_date_sk = ss_sold_date_sk
  30. and d_moy=12
  31. and d_year=2000
  32. ) tmp,plato.time_dim
  33. where
  34. sold_item_sk = i_item_sk
  35. and i_manager_id=1
  36. and time_sk = t_time_sk
  37. and (t_meal_time = 'breakfast' or t_meal_time = 'dinner')
  38. group by i_brand, i_brand_id,t_hour,t_minute
  39. order by ext_price desc, i_brand_id
  40. ;
  41. -- end query 1 in stream 0 using template ../query_templates/query71.tpl