Created
August 31, 2018 10:07
-
-
Save markuman/ed9a80e3d3cc8bf6a3747a9628e59216 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
with commits as( | |
select | |
created_unix as time_sec, | |
count(user_id) as value, | |
DATE_FORMAT( FROM_UNIXTIME(created_unix), | |
'%Y-%m-%d' ) as dates | |
from | |
`action` | |
where | |
user_id = 1 | |
group by | |
DATE_FORMAT( FROM_UNIXTIME(created_unix), | |
'%Y%m%d' ) | |
order by | |
created_unix ) select | |
ifnull( time_sec, | |
UNIX_TIMESTAMP(my_dates.dates)) as time_sec, | |
ifnull( value, | |
0 ) as value, | |
'commits' as metric | |
from | |
my_dates | |
left join commits on | |
( commits.dates = my_dates.dates ) | |
where | |
$__timeFilter(my_dates.dates) | |
order by | |
my_dates.dates |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment