q69.sql 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. --!syntax_pg
  2. --TPC-DS Q69
  3. -- start query 1 in stream 0 using template ../query_templates/query69.tpl
  4. select
  5. cd_gender,
  6. cd_marital_status,
  7. cd_education_status,
  8. count(*) cnt1,
  9. cd_purchase_estimate,
  10. count(*) cnt2,
  11. cd_credit_rating,
  12. count(*) cnt3
  13. from
  14. plato.customer c,plato.customer_address ca,plato.customer_demographics
  15. where
  16. c.c_current_addr_sk = ca.ca_address_sk and
  17. ca_state in ('CO','IL','MN') and
  18. cd_demo_sk = c.c_current_cdemo_sk and
  19. exists (select *
  20. from plato.store_sales,plato.date_dim
  21. where c.c_customer_sk = ss_customer_sk and
  22. ss_sold_date_sk = d_date_sk and
  23. d_year = 1999 and
  24. d_moy between 1 and 1+2) and
  25. (not exists (select *
  26. from plato.web_sales,plato.date_dim
  27. where c.c_customer_sk = ws_bill_customer_sk and
  28. ws_sold_date_sk = d_date_sk and
  29. d_year = 1999 and
  30. d_moy between 1 and 1+2) and
  31. not exists (select *
  32. from plato.catalog_sales,plato.date_dim
  33. where c.c_customer_sk = cs_ship_customer_sk and
  34. cs_sold_date_sk = d_date_sk and
  35. d_year = 1999 and
  36. d_moy between 1 and 1+2))
  37. group by cd_gender,
  38. cd_marital_status,
  39. cd_education_status,
  40. cd_purchase_estimate,
  41. cd_credit_rating
  42. order by cd_gender,
  43. cd_marital_status,
  44. cd_education_status,
  45. cd_purchase_estimate,
  46. cd_credit_rating
  47. limit 100;
  48. -- end query 1 in stream 0 using template ../query_templates/query69.tpl