Skip to content

Instantly share code, notes, and snippets.

@stompro
Created July 20, 2017 04:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stompro/ca50f835142646f71691b4ac40473608 to your computer and use it in GitHub Desktop.
Save stompro/ca50f835142646f71691b4ac40473608 to your computer and use it in GitHub Desktop.
Evergreen actor.card adding creation date and time
-- Use history to find the date and staff member that changed the card
select * from (
select aauh.audit_id, aauh.audit_time, aauh.audit_user, aauh.card, aauh.id
,lead(aauh.card) OVER (PARTITION BY aauh.id ORDER BY aauh.audit_time) as next_card
from auditor.actor_usr_lifecycle aauh
where aauh.id > 112900
--and aauh.id=124212
order by aauh.id, aauh.audit_time
--limit 10000
) x
where
( x.card!=x.next_card )
;
-- Test case
select *
from auditor.actor_usr_lifecycle aaul
where
id=124212
order by audit_time
;
-- Test Case
select * from actor.card where usr=124212;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment