longgb246的博客

例子

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
CREATE TABLE dev.tmp_check_sku_20161202
AS
SELECT
a.item_sku_id,
b.sku_id
FROM
(SELECT item_sku_id,dt
FROM
gdm.gdm_m03_item_sku_da
WHERE dt= '2016-10-08'
AND sku_valid_flag=1) A
FULL OUTER JOIN
(SELECT sku_id,dt
FROM gdm.gdm_m08_item_stock_day_sum
WHERE dt= '2016-10-08'
) B
ON a.item_sku_id=b.sku_id
1
2
3
4
5
6
7
8
9
10
11
12
13
14
-- 统计数据
SELECT
CASE WHEN item_sku_id IS NOT NULL THEN 1 ELSE 0 END AS item_sku_cnt,
CASE WHEN sku_id IS NOT NULL THEN 1 ELSE 0 END AS sku_cnt,
count(1)
FROM
dev.tmp_check_sku_20161202
GROUP BY
CASE WHEN item_sku_id IS NOT NULL THEN 1 ELSE 0 END,
CASE WHEN sku_id IS NOT NULL THEN 1 ELSE 0 END
-- 结果
1 0 1 707489
2 1 0 832084258
3 1 1 81142196
坚持原创技术分享,您的支持将鼓励我继续创作!