query27.sql 873 B

1234567891011121314151617181920212223
  1. select i_item_id,
  2. s_state,
  3. avg(ss_quantity) agg1,
  4. avg(ss_list_price) agg2,
  5. avg(ss_coupon_amt) agg3,
  6. avg(ss_sales_price) agg4
  7. from store_sales, customer_demographics, date_dim, store, item
  8. where store_sales.ss_sold_date_sk = date_dim.d_date_sk and
  9. store_sales.ss_item_sk = item.i_item_sk and
  10. store_sales.ss_store_sk = store.s_store_sk and
  11. store_sales.ss_cdemo_sk = customer_demographics.cd_demo_sk and
  12. customer_demographics.cd_gender = 'F' and
  13. customer_demographics.cd_marital_status = 'D' and
  14. customer_demographics.cd_education_status = 'Unknown' and
  15. date_dim.d_year = 1998 and
  16. ss_sold_date between '1998-01-01' and '1998-12-31' and
  17. store.s_state in ('KS','AL', 'MN', 'AL', 'SC', 'VT')
  18. group by i_item_id, s_state
  19. order by i_item_id
  20. ,s_state
  21. limit 100;