q10.sql 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. --!syntax_pg
  2. --TPC-DS Q10
  3. -- start query 1 in stream 0 using template ../query_templates/query10.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. cd_dep_count,
  14. count(*) cnt4,
  15. cd_dep_employed_count,
  16. count(*) cnt5,
  17. cd_dep_college_count,
  18. count(*) cnt6
  19. from
  20. plato.customer c,plato.customer_address ca,plato.customer_demographics
  21. where
  22. c.c_current_addr_sk = ca.ca_address_sk and
  23. ca_county in ('Walker County','Richland County','Gaines County','Douglas County','Dona Ana County') and
  24. cd_demo_sk = c.c_current_cdemo_sk and
  25. exists (select *
  26. from plato.store_sales,plato.date_dim
  27. where c.c_customer_sk = ss_customer_sk and
  28. ss_sold_date_sk = d_date_sk and
  29. d_year = 2002 and
  30. d_moy between 4 and 4+3) and
  31. (exists (select *
  32. from plato.web_sales,plato.date_dim
  33. where c.c_customer_sk = ws_bill_customer_sk and
  34. ws_sold_date_sk = d_date_sk and
  35. d_year = 2002 and
  36. d_moy between 4 ANd 4+3) or
  37. exists (select *
  38. from plato.catalog_sales,plato.date_dim
  39. where c.c_customer_sk = cs_ship_customer_sk and
  40. cs_sold_date_sk = d_date_sk and
  41. d_year = 2002 and
  42. d_moy between 4 and 4+3))
  43. group by cd_gender,
  44. cd_marital_status,
  45. cd_education_status,
  46. cd_purchase_estimate,
  47. cd_credit_rating,
  48. cd_dep_count,
  49. cd_dep_employed_count,
  50. cd_dep_college_count
  51. order by cd_gender,
  52. cd_marital_status,
  53. cd_education_status,
  54. cd_purchase_estimate,
  55. cd_credit_rating,
  56. cd_dep_count,
  57. cd_dep_employed_count,
  58. cd_dep_college_count
  59. limit 100;
  60. -- end query 1 in stream 0 using template ../query_templates/query10.tpl