标签:bsp null ase sel count mysql time tin amp
SELECT
CASE
WHEN //当count(userId) = 0的时候 让其为null 不然报警告
// count(DISTINCT userId) 不用处理
count(userId) = 0 THEN
NULL
ELSE
ROUND(
count(userId) / count(DISTINCT userId)
)
END AS r
FROM
video_user_his AS a
WHERE
UNIX_TIMESTAMP(a.createTime) < 1486828800
AND UNIX_TIMESTAMP(a.createTime) > 1486915199
标签:bsp null ase sel count mysql time tin amp
原文地址:http://www.cnblogs.com/wanghaonull/p/6424769.html