q06.sql 885 B

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