Skip to content

Instantly share code, notes, and snippets.

@cameri
Created August 31, 2014 02:28
Show Gist options
  • Save cameri/e20473083ca93779aa9a to your computer and use it in GitHub Desktop.
Save cameri/e20473083ca93779aa9a to your computer and use it in GitHub Desktop.
SELECT `business_id`,`venue_id`, `VenueHour`.`days`,
GROUP_CONCAT(
CONCAT(
(`VenueHour`.`begin_hour` >> 4)%12,
':',
LPAD((`VenueHour`.`begin_hour` & 15)*5,2,'0'),
IF(`VenueHour`.`begin_hour` < 192, ' a.m.', ' p.m.'),
' - ',
(`VenueHour`.`end_hour` >> 4)%12,
':',
LPAD((`VenueHour`.`end_hour` & 15)*5,2,'0'),
IF(`VenueHour`.`end_hour` < 192, ' a.m.', ' p.m.')
) SEPARATOR ',') as `hours`
FROM `venue_hours` AS `VenueHour`
GROUP BY `VenueHour`.`business_id`, `VenueHour`.`venue_id`,`VenueHour`.`days`
ORDER BY `VenueHour`.`begin_hour`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment