Skip to content

Instantly share code, notes, and snippets.

@dboyd13
Last active February 16, 2018 07:57
Show Gist options
  • Save dboyd13/67540ed5df340221c38e5c4929921e7d to your computer and use it in GitHub Desktop.
Save dboyd13/67540ed5df340221c38e5c4929921e7d to your computer and use it in GitHub Desktop.
# Purpose:
# SELECT: All DRINKS of a specific Keg
# OUTPUT: Drink ID, Day of Week, Date and time (localtime),
# SORTED BY: Volume_ml
select id, substr('SunMonTueWedThuFriSat', 1 + 3*strftime('%w', datetime(time, "localtime")), 3), datetime(time, "localtime"), volume_ml from core_drink where keg_id=61 ORDER BY volume_ml;
# Purpose:
# SELECT: All DRINKS of a specific Keg ONLY if weekday (Mon-Fri)
# OUTPUT: Drink ID, Day of Week, Date and time (localtime)
select id, substr('SunMonTueWedThuFriSat', 1 + 3*strftime('%w', datetime(time, "localtime")), 3) as dow, datetime(time, "localtime"), volume_ml from core_drink where keg_id=61 AND (dow = "Mon" or dow = "Tue" or dow = "Wed" or dow = "Thu" or dow = "Fri");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment