forked from agirish/tpcds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
query76.sql
57 lines (57 loc) · 1.75 KB
/
query76.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
-- start query 76 in stream 0 using template query76.tpl
SELECT channel,
col_name,
d_year,
d_qoy,
i_category,
Count(*) sales_cnt,
Sum(ext_sales_price) sales_amt
FROM (SELECT 'store' AS channel,
'ss_hdemo_sk' col_name,
d_year,
d_qoy,
i_category,
ss_ext_sales_price ext_sales_price
FROM store_sales,
item,
date_dim
WHERE ss_hdemo_sk IS NULL
AND ss_sold_date_sk = d_date_sk
AND ss_item_sk = i_item_sk
UNION ALL
SELECT 'web' AS channel,
'ws_ship_hdemo_sk' col_name,
d_year,
d_qoy,
i_category,
ws_ext_sales_price ext_sales_price
FROM web_sales,
item,
date_dim
WHERE ws_ship_hdemo_sk IS NULL
AND ws_sold_date_sk = d_date_sk
AND ws_item_sk = i_item_sk
UNION ALL
SELECT 'catalog' AS channel,
'cs_warehouse_sk' col_name,
d_year,
d_qoy,
i_category,
cs_ext_sales_price ext_sales_price
FROM catalog_sales,
item,
date_dim
WHERE cs_warehouse_sk IS NULL
AND cs_sold_date_sk = d_date_sk
AND cs_item_sk = i_item_sk) foo
GROUP BY channel,
col_name,
d_year,
d_qoy,
i_category
ORDER BY channel,
col_name,
d_year,
d_qoy,
i_category
LIMIT 100;