Skip to content

Instantly share code, notes, and snippets.

@zacclark
Created May 11, 2011 19:24
Show Gist options
  • Save zacclark/967114 to your computer and use it in GitHub Desktop.
Save zacclark/967114 to your computer and use it in GitHub Desktop.
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