q35.sql 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. --!syntax_pg
  2. --TPC-DS Q35
  3. -- start query 1 in stream 0 using template ../query_templates/query35.tpl
  4. select
  5. ca_state,
  6. cd_gender,
  7. cd_marital_status,
  8. cd_dep_count,
  9. count(*) cnt1,
  10. avg(cd_dep_count) a1,
  11. max(cd_dep_count) x1,
  12. sum(cd_dep_count) s1,
  13. cd_dep_employed_count,
  14. count(*) cnt2,
  15. avg(cd_dep_employed_count) a2,
  16. max(cd_dep_employed_count) x2,
  17. sum(cd_dep_employed_count) s2,
  18. cd_dep_college_count,
  19. count(*) cnt3,
  20. avg(cd_dep_college_count) a3,
  21. max(cd_dep_college_count) x3,
  22. sum(cd_dep_college_count) s3
  23. from
  24. plato.customer c,plato.customer_address ca,plato.customer_demographics
  25. where
  26. c.c_current_addr_sk = ca.ca_address_sk and
  27. cd_demo_sk = c.c_current_cdemo_sk and
  28. exists (select *
  29. from plato.store_sales,plato.date_dim
  30. where c.c_customer_sk = ss_customer_sk and
  31. ss_sold_date_sk = d_date_sk and
  32. d_year = 1999 and
  33. d_qoy < 4) and
  34. (exists (select *
  35. from plato.web_sales,plato.date_dim
  36. where c.c_customer_sk = ws_bill_customer_sk and
  37. ws_sold_date_sk = d_date_sk and
  38. d_year = 1999 and
  39. d_qoy < 4) or
  40. exists (select *
  41. from plato.catalog_sales,plato.date_dim
  42. where c.c_customer_sk = cs_ship_customer_sk and
  43. cs_sold_date_sk = d_date_sk and
  44. d_year = 1999 and
  45. d_qoy < 4))
  46. group by ca_state,
  47. cd_gender,
  48. cd_marital_status,
  49. cd_dep_count,
  50. cd_dep_employed_count,
  51. cd_dep_college_count
  52. order by ca_state,
  53. cd_gender,
  54. cd_marital_status,
  55. cd_dep_count,
  56. cd_dep_employed_count,
  57. cd_dep_college_count
  58. limit 100;
  59. -- end query 1 in stream 0 using template ../query_templates/query35.tpl