Skip to content

Instantly share code, notes, and snippets.

@Kimserey
Created April 21, 2016 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kimserey/1470cb0e51d91fede084ea0ecae104e9 to your computer and use it in GitHub Desktop.
Save Kimserey/1470cb0e51d91fede084ea0ecae104e9 to your computer and use it in GitHub Desktop.
Events per day
/* events per day */
SELECT
DATE(timestamp / 10000000 - 62135596800, 'unixepoch') as date,
(CASE
WHEN strftime('%w', DATE(timestamp / 10000000 - 62135596800, 'unixepoch')) == '0' THEN 'Sunday'
WHEN strftime('%w', DATE(timestamp / 10000000 - 62135596800, 'unixepoch')) == '1' THEN 'Monday'
WHEN strftime('%w', DATE(timestamp / 10000000 - 62135596800, 'unixepoch')) == '2' THEN 'Tuesday'
WHEN strftime('%w', DATE(timestamp / 10000000 - 62135596800, 'unixepoch')) == '3' THEN 'Wednesday'
WHEN strftime('%w', DATE(timestamp / 10000000 - 62135596800, 'unixepoch')) == '4' THEN 'Thursday'
WHEN strftime('%w', DATE(timestamp / 10000000 - 62135596800, 'unixepoch')) == '5' THEN 'Friday'
WHEN strftime('%w', DATE(timestamp / 10000000 - 62135596800, 'unixepoch')) == '6' THEN 'Saturday'
END) as 'day of the week',
count(*) as 'count of events'
from events
group by date
order by date desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment