query22.sql 677 B

12345678910111213141516171819
  1. select i_product_name
  2. ,i_brand
  3. ,i_class
  4. ,i_category
  5. ,avg(inv_quantity_on_hand) qoh
  6. from inventory
  7. ,date_dim
  8. ,item
  9. ,warehouse
  10. where inventory.inv_date_sk=date_dim.d_date_sk
  11. and inventory.inv_item_sk=item.i_item_sk
  12. and inventory.inv_warehouse_sk = warehouse.w_warehouse_sk
  13. and date_dim.d_month_seq between 1193 and 1193 + 11
  14. group by i_product_name
  15. ,i_brand
  16. ,i_class
  17. ,i_category with rollup
  18. order by qoh, i_product_name, i_brand, i_class, i_category
  19. limit 100;