Created
December 11, 2015 12:10
-
-
Save yukihirai0505/a8c1e31ec1d453e868d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET @t = 2; | |
SELECT | |
SUM(A.counter) AS counter | |
FROM | |
(SELECT | |
FROM_UNIXTIME(CEILING(UNIX_TIMESTAMP(access_date) / (@t * 60)) * (@t * 60)) AS access_date, | |
1 AS counter | |
FROM | |
tmp_user | |
GROUP BY CEILING(UNIX_TIMESTAMP(access_date) / (@t * 60)) * (@t * 60)) A | |
GROUP BY DATE_FORMAT(A.access_date, '%Y%m%d'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment