Created
May 11, 2011 19:24
-
-
Save zacclark/967114 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
people.id as person, | |
statuses.status as original, | |
actions.status_code as copy, | |
statuses.created_at, | |
actions.occurred_at | |
from | |
people | |
JOIN attendances ON attendances.person_id = people.id | |
JOIN statuses ON statuses.id = attendances.current_status_id | |
JOIN actions ON actions.id = attendances.latest_status_change_action_id | |
WHERE | |
statuses.attendance_id = actions.attendance_id | |
AND | |
NOT (statuses.status = actions.status_code) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment