query6.sql 790 B

1234567891011121314151617181920212223242526
  1. -- start query 1 in stream 0 using template query6.tpl and seed 1819994127
  2. select a.ca_state state, count(*) cnt
  3. from customer_address a
  4. ,customer c
  5. ,store_sales s
  6. ,date_dim d
  7. ,item i
  8. where a.ca_address_sk = c.c_current_addr_sk
  9. and c.c_customer_sk = s.ss_customer_sk
  10. and s.ss_sold_date_sk = d.d_date_sk
  11. and s.ss_item_sk = i.i_item_sk
  12. and d.d_month_seq =
  13. (select distinct (d_month_seq)
  14. from date_dim
  15. where d_year = 2002
  16. and d_moy = 3 )
  17. and i.i_current_price > 1.2 *
  18. (select avg(j.i_current_price)
  19. from item j
  20. where j.i_category = i.i_category)
  21. group by a.ca_state
  22. having count(*) >= 10
  23. order by cnt, a.ca_state
  24. limit 100;
  25. -- end query 1 in stream 0 using template query6.tpl