forked from agirish/tpcds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
query35.sql
58 lines (58 loc) · 2.19 KB
/
query35.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
-- start query 35 in stream 0 using template query35.tpl
SELECT ca_state,
cd_gender,
cd_marital_status,
cd_dep_count,
Count(*) cnt1,
Stddev_samp(cd_dep_count),
Avg(cd_dep_count),
Max(cd_dep_count),
cd_dep_employed_count,
Count(*) cnt2,
Stddev_samp(cd_dep_employed_count),
Avg(cd_dep_employed_count),
Max(cd_dep_employed_count),
cd_dep_college_count,
Count(*) cnt3,
Stddev_samp(cd_dep_college_count),
Avg(cd_dep_college_count),
Max(cd_dep_college_count)
FROM customer c,
customer_address ca,
customer_demographics
WHERE c.c_current_addr_sk = ca.ca_address_sk
AND cd_demo_sk = c.c_current_cdemo_sk
AND EXISTS (SELECT *
FROM store_sales,
date_dim
WHERE c.c_customer_sk = ss_customer_sk
AND ss_sold_date_sk = d_date_sk
AND d_year = 2001
AND d_qoy < 4)
AND ( EXISTS (SELECT *
FROM web_sales,
date_dim
WHERE c.c_customer_sk = ws_bill_customer_sk
AND ws_sold_date_sk = d_date_sk
AND d_year = 2001
AND d_qoy < 4)
OR EXISTS (SELECT *
FROM catalog_sales,
date_dim
WHERE c.c_customer_sk = cs_ship_customer_sk
AND cs_sold_date_sk = d_date_sk
AND d_year = 2001
AND d_qoy < 4) )
GROUP BY ca_state,
cd_gender,
cd_marital_status,
cd_dep_count,
cd_dep_employed_count,
cd_dep_college_count
ORDER BY ca_state,
cd_gender,
cd_marital_status,
cd_dep_count,
cd_dep_employed_count,
cd_dep_college_count
LIMIT 100;