Skip to content

Instantly share code, notes, and snippets.

@mustmodify
Created September 11, 2014 20:21
Show Gist options
  • Save mustmodify/1a910d2385a48cbfe204 to your computer and use it in GitHub Desktop.
Save mustmodify/1a910d2385a48cbfe204 to your computer and use it in GitHub Desktop.
select count(DISTINCT(appointments.id)) from appointments LEFT JOIN pictures ON pictures.appointment_id = appointments.id LEFT JOIN routes ON appointments.route_id = routes.id WHERE pictures.created_at IS NOT NULL AND DATE(CONVERT_TZ(MIN(pictures.created_at), 'UTC', 'US/Eastern')) != routes.date GROUP BY appointments.id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment