forked from agirish/tpcds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
query13.sql
44 lines (44 loc) · 1.92 KB
/
query13.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
-- start query 13 in stream 0 using template query13.tpl
SELECT Avg(ss_quantity),
Avg(ss_ext_sales_price),
Avg(ss_ext_wholesale_cost),
Sum(ss_ext_wholesale_cost)
FROM store_sales,
store,
customer_demographics,
household_demographics,
customer_address,
date_dim
WHERE s_store_sk = ss_store_sk
AND ss_sold_date_sk = d_date_sk
AND d_year = 2001
AND ( ( ss_hdemo_sk = hd_demo_sk
AND cd_demo_sk = ss_cdemo_sk
AND cd_marital_status = 'U'
AND cd_education_status = 'Advanced Degree'
AND ss_sales_price BETWEEN 100.00 AND 150.00
AND hd_dep_count = 3 )
OR ( ss_hdemo_sk = hd_demo_sk
AND cd_demo_sk = ss_cdemo_sk
AND cd_marital_status = 'M'
AND cd_education_status = 'Primary'
AND ss_sales_price BETWEEN 50.00 AND 100.00
AND hd_dep_count = 1 )
OR ( ss_hdemo_sk = hd_demo_sk
AND cd_demo_sk = ss_cdemo_sk
AND cd_marital_status = 'D'
AND cd_education_status = 'Secondary'
AND ss_sales_price BETWEEN 150.00 AND 200.00
AND hd_dep_count = 1 ) )
AND ( ( ss_addr_sk = ca_address_sk
AND ca_country = 'United States'
AND ca_state IN ( 'AZ', 'NE', 'IA' )
AND ss_net_profit BETWEEN 100 AND 200 )
OR ( ss_addr_sk = ca_address_sk
AND ca_country = 'United States'
AND ca_state IN ( 'MS', 'CA', 'NV' )
AND ss_net_profit BETWEEN 150 AND 300 )
OR ( ss_addr_sk = ca_address_sk
AND ca_country = 'United States'
AND ca_state IN ( 'GA', 'TX', 'NJ' )
AND ss_net_profit BETWEEN 50 AND 250 ) );