Last active
July 29, 2017 16:42
-
-
Save steverobbins/bffcb136a65c9f1b32d5 to your computer and use it in GitHub Desktop.
This file contains 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
select | |
`Time Period`, | |
round(avg(num), 1) `Average Number of Orders` | |
from ( | |
select | |
date_format(date_sub(o.created_at, interval 8 hour), "%l:00 - %l:59 %p PST") `Time Period`, | |
count(*) num, | |
date_format(date_sub(o.created_at, interval 8 hour), "%H") sort | |
from sales_flat_order o | |
where o.created_at > '2016-01-01 00:00:00' | |
and o.created_at < '2016-02-01 00:00:00' | |
group by date_format(date_sub(o.created_at, interval 8 hour), "%Y-%m-%d-%H") | |
) t | |
group by `Time Period` | |
order by sort; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment