SQL执行顺序:
With as --> FROM(JOIN 部分一般先左后右) --> WHERE --> GROUP BY --> HAVING --> SELECT --> ORDER BY
-- 本语句为某视频网站公司对于k-pop业务线的各渠道用户、新增用户数据抽取语句
with temp_active_hour_table_kps as
(
select
a0.dt
,product_id
,mkey
,substr(FROM_UNIXTIME(st_time),12,2) as hour
,a0.device_id
from
(
select
dt
,product_id
,st_time
,device_id
from
kps_dwd.kps_dwd_dd_view_user_active
where dt='${dt_1}'
) a0