按照分析周期(period)统计关注、意向、增长
方法一:
SELECT
COUNT(*) AS cnt,
concern AS type_name
FROM
dws_imei_browse_tag
WHERE
concern = '关注'
AND period = '2020Q1' UNION ALL
SELECT
COUNT(*) AS cnt,
intention AS type_name
FROM
dws_imei_browse_tag
WHERE
intention = '意向'
AND period = '2020Q1' UNION ALL
SELECT
COUNT(*) AS cnt,
cre AS type_name
FROM
dws_imei_browse_tag
WHERE
cre = '增长'
AND period = '2020Q1'
查询结果:
方法二:
SELECT
sum( CASE WHEN concern = '关注' THEN 1 ELSE 0 END ) gz,
sum( CASE WHEN intention = '意向' THEN 1 ELSE 0 END ) yx,
sum( CASE WHEN cre = '增长' THEN 1 ELSE 0 END ) zz,
period
FROM
dws_imei_browse_tag
WHERE
period = '2020Q1'