query3.sql 456 B

123456789101112131415161718
  1. select dt.d_year
  2. ,item.i_brand_id brand_id
  3. ,item.i_brand brand
  4. ,sum(ss_ext_sales_price) sum_agg
  5. from date_dim dt
  6. ,store_sales
  7. ,item
  8. where dt.d_date_sk = store_sales.ss_sold_date_sk
  9. and store_sales.ss_item_sk = item.i_item_sk
  10. and item.i_manufact_id = 436
  11. and dt.d_moy=12
  12. group by dt.d_year
  13. ,item.i_brand
  14. ,item.i_brand_id
  15. order by dt.d_year
  16. ,sum_agg desc
  17. ,brand_id
  18. limit 100;