query45.sql 749 B

123456789101112131415161718
  1. select ca_zip, ca_county, sum(ws_sales_price)
  2. from
  3. web_sales
  4. JOIN customer ON web_sales.ws_bill_customer_sk = customer.c_customer_sk
  5. JOIN customer_address ON customer.c_current_addr_sk = customer_address.ca_address_sk
  6. JOIN date_dim ON web_sales.ws_sold_date_sk = date_dim.d_date_sk
  7. JOIN item ON web_sales.ws_item_sk = item.i_item_sk
  8. where
  9. ( item.i_item_id in (select i_item_id
  10. from item i2
  11. where i2.i_item_sk in (2, 3, 5, 7, 11, 13, 17, 19, 23, 29)
  12. )
  13. )
  14. and d_qoy = 2 and d_year = 2000
  15. and ws_sold_date between '2000-04-01' and '2000-06-30'
  16. group by ca_zip, ca_county
  17. order by ca_zip, ca_county
  18. limit 100;