-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathquery91.sql
32 lines (32 loc) · 1.13 KB
/
query91.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
-- start query 91 in stream 0 using template query91.tpl
SELECT cc_call_center_id Call_Center,
cc_name Call_Center_Name,
cc_manager Manager,
Sum(cr_net_loss) Returns_Loss
FROM call_center,
catalog_returns,
date_dim,
customer,
customer_address,
customer_demographics,
household_demographics
WHERE cr_call_center_sk = cc_call_center_sk
AND cr_returned_date_sk = d_date_sk
AND cr_returning_customer_sk = c_customer_sk
AND cd_demo_sk = c_current_cdemo_sk
AND hd_demo_sk = c_current_hdemo_sk
AND ca_address_sk = c_current_addr_sk
AND d_year = 1999
AND d_moy = 12
AND ( ( cd_marital_status = 'M'
AND cd_education_status = 'Unknown' )
OR ( cd_marital_status = 'W'
AND cd_education_status = 'Advanced Degree' ) )
AND hd_buy_potential LIKE 'Unknown%'
AND ca_gmt_offset = -7
GROUP BY cc_call_center_id,
cc_name,
cc_manager,
cd_marital_status,
cd_education_status
ORDER BY Sum(cr_net_loss) DESC;