forked from agirish/tpcds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
query62.sql
45 lines (45 loc) · 1.71 KB
/
query62.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
-- start query 62 in stream 0 using template query62.tpl
SELECT Substr(w_warehouse_name, 1, 20),
sm_type,
web_name,
Sum(CASE
WHEN ( ws_ship_date_sk - ws_sold_date_sk <= 30 ) THEN 1
ELSE 0
END) AS `30 days`,
Sum(CASE
WHEN ( ws_ship_date_sk - ws_sold_date_sk > 30 )
AND ( ws_ship_date_sk - ws_sold_date_sk <= 60 ) THEN 1
ELSE 0
END) AS `31-60 days`,
Sum(CASE
WHEN ( ws_ship_date_sk - ws_sold_date_sk > 60 )
AND ( ws_ship_date_sk - ws_sold_date_sk <= 90 ) THEN 1
ELSE 0
END) AS `61-90 days`,
Sum(CASE
WHEN ( ws_ship_date_sk - ws_sold_date_sk > 90 )
AND ( ws_ship_date_sk - ws_sold_date_sk <= 120 ) THEN
1
ELSE 0
END) AS `91-120 days`,
Sum(CASE
WHEN ( ws_ship_date_sk - ws_sold_date_sk > 120 ) THEN 1
ELSE 0
END) AS `>120 days`
FROM web_sales,
warehouse,
ship_mode,
web_site,
date_dim
WHERE d_month_seq BETWEEN 1222 AND 1222 + 11
AND ws_ship_date_sk = d_date_sk
AND ws_warehouse_sk = w_warehouse_sk
AND ws_ship_mode_sk = sm_ship_mode_sk
AND ws_web_site_sk = web_site_sk
GROUP BY Substr(w_warehouse_name, 1, 20),
sm_type,
web_name
ORDER BY Substr(w_warehouse_name, 1, 20),
sm_type,
web_name
LIMIT 100;