0001 SELECT
0002 ca_state,
0003 cd_gender,
0004 cd_marital_status,
0005 count(*) cnt1,
0006 min(cd_dep_count),
0007 max(cd_dep_count),
0008 avg(cd_dep_count),
0009 cd_dep_employed_count,
0010 count(*) cnt2,
0011 min(cd_dep_employed_count),
0012 max(cd_dep_employed_count),
0013 avg(cd_dep_employed_count),
0014 cd_dep_college_count,
0015 count(*) cnt3,
0016 min(cd_dep_college_count),
0017 max(cd_dep_college_count),
0018 avg(cd_dep_college_count)
0019 FROM
0020 customer c, customer_address ca, customer_demographics
0021 WHERE
0022 c.c_current_addr_sk = ca.ca_address_sk AND
0023 cd_demo_sk = c.c_current_cdemo_sk AND
0024 exists(SELECT *
0025 FROM store_sales, date_dim
0026 WHERE c.c_customer_sk = ss_customer_sk AND
0027 ss_sold_date_sk = d_date_sk AND
0028 d_year = 2002 AND
0029 d_qoy < 4) AND
0030 (exists(SELECT *
0031 FROM web_sales, date_dim
0032 WHERE c.c_customer_sk = ws_bill_customer_sk AND
0033 ws_sold_date_sk = d_date_sk AND
0034 d_year = 2002 AND
0035 d_qoy < 4) OR
0036 exists(SELECT *
0037 FROM catalog_sales, date_dim
0038 WHERE c.c_customer_sk = cs_ship_customer_sk AND
0039 cs_sold_date_sk = d_date_sk AND
0040 d_year = 2002 AND
0041 d_qoy < 4))
0042 GROUP BY ca_state, cd_gender, cd_marital_status, cd_dep_count,
0043 cd_dep_employed_count, cd_dep_college_count
0044 ORDER BY ca_state, cd_gender, cd_marital_status, cd_dep_count,
0045 cd_dep_employed_count, cd_dep_college_count
0046 LIMIT 100