统计 一天24小时 每个小时的数据总数
2019-06-28 本文已影响2人
端木安玉
先看效果
image.png
SELECT
vid,FROM_UNIXTIME(time,'%Y-%m-%d %H') AS Hour,
count(*) AS Count
FROM
vote_detail
WHERE
FROM_UNIXTIME(time, '%Y-%m-%d %H') < '2019-06-25 17'
and
vid =12
GROUP BY
FROM_UNIXTIME(time,'%Y-%m-%d %H')
HAVING count(*) >20
ORDER BY
FROM_UNIXTIME(time,'%Y-%m-%d %H');
亲测有效