Skip to content

Instantly share code, notes, and snippets.

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 joebartels/b0559becc782443238669c722167f6ca to your computer and use it in GitHub Desktop.
Save joebartels/b0559becc782443238669c722167f6ca to your computer and use it in GitHub Desktop.
query cycling_entry by day of week and hour of day
select sum(km_cycled) as km_cycled_for_all_mondays
from cycling_entry
where day_of_week = 1
and hour_of_day > 11;
-- result: 39982
-- average time: 7.25ms
select sum(km_cycled) as km_cycled_for_all_mondays
from cycling_entry
where extract(dow from date) = 1
and extract(hour from date) > 11;
-- result: 39982
-- average time: 19.2ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment