阅读背景:

自然周与自然月的Hive统计SQL

来源:互联网 

按照周或者月统计活跃数:

周:

SELECT week, COUNT(DISTINCT pin), business_type
FROM (
	SELECT DISTINCT user_log_acct AS pin,weekofyear(dt) AS week
		, CASE locate('bdp', url_domain)
			WHEN 0 THEN 'pinpiao'
			ELSE 'caixiao'
		END AS business_type
	FROM gdm.gdm_online_log
	WHERE ((url_domain LIKE '%tmall.com%'
			OR url_domain LIKE '%bdp.tmall.com%')
		AND user_log_acct NOT IN ('xxx', 'xx111', 'xxx22')
		AND dt >= '2018-07-30')
) weekTab
GROUP BY week, business_type;
SELECT week, COUNT(DIST



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: