-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtaker_press.sql
62 lines (56 loc) · 1.74 KB
/
taker_press.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
59
60
61
62
SELECT count(eleme_order_id) order_num
FROM dw_aly.dw_al_tms_apollo_waybill_wide
WHERE dt = '2016-11-08'
AND created_at > get_date(-1)
AND shipping_state = 40
GROUP BY taker_id
limit 200;
SELECT a.taker_id,
overtime_sum/sum overtime_ratio
FROM
(SELECT taker_id,
count(*) sum
FROM dw_aly.dw_al_tms_apollo_waybill_wide
WHERE dt = '2016-11-09'
AND created_at > get_date(-1)
AND shipping_state = 40
GROUP BY taker_id ) a
JOIN
(SELECT taker_id,
count(*) overtime_sum
FROM dw_aly.dw_al_tms_apollo_waybill_wide
WHERE dt = '2016-11-09'
AND created_at > get_date(-1)
AND shipping_state = 40
AND is_overtime = 1
GROUP BY taker_id ) b
ON a.taker_id = b.taker_id
order by overtime_ratio desc
limit 500;
select * from dw_aly.dw_al_tms_apollo_waybill_wide
where dt = '2016-11-09'
AND created_at > get_date(-1)
AND shipping_state = 40
and taker_id in
(
SELECT a.taker_id
FROM
(SELECT taker_id,
count(*) sum
FROM dw_aly.dw_al_tms_apollo_waybill_wide
WHERE dt = '2016-11-09'
AND created_at > get_date(-1)
AND shipping_state = 40
GROUP BY taker_id ) a
JOIN
(SELECT taker_id,
count(*) overtime_sum
FROM dw_aly.dw_al_tms_apollo_waybill_wide
WHERE dt = '2016-11-09'
AND created_at > get_date(-1)
AND shipping_state = 40
AND is_overtime = 1
GROUP BY taker_id ) b
ON a.taker_id = b.taker_id
order by overtime_sum/sum desc limit 200
)