需求
统计某一天内,启动应用的设备总数,以及不同渠道来源的设备数量。
sql
数据库是mysql
SET @date = 'yyyy-MM-dd%';
SELECT
COUNT(
DISTINCT CASE
WHEN create_date LIKE @date THEN
imei
END
) AS total,
COUNT(
DISTINCT CASE
WHEN create_date LIKE @date
AND channel = 'google' THEN
imei
END
) AS update_dialog,
COUNT(
DISTINCT CASE
WHEN create_date LIKE @date
AND channel = 'qq' THEN
imei
END
) AS update_now
FROM
t_app_download
WHERE
appid= "com.app.test"