query27.sql 811 B

12345678910111213141516171819202122
  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. store.s_state in ('KS','AL', 'MN', 'AL', 'SC', 'VT')
  17. group by i_item_id, s_state
  18. order by i_item_id
  19. ,s_state
  20. limit 100;