General information
Forum:
Microsoft SQL Server
Title:
Self join challenge..
Hi All,
Ok, here is what I need help with. I have a table which is audit data of a parent table. Basically, it is the same schema as the table it audits with a few fields added, audit_id, audit_datetime, audit_imageType, audit_username.
How can I query this data so that I can join a record to the record that comes before it cronologically where the key of the record it audit matches. I want to do this so I can get the old value and new value for an audit report.
Any ideas? Here is a small snippet of one of the audit tables, ee_id is the primary key of the table.
audit_id
, audit_datetime
, audit_imageType
, audit_username
, ee_id
, empnum
, fname
, mname
, lname
So, I want to end up with a return of:
audit_datetime
,audit_username
,ee_id_old
,ee_id_new
,empnum_old
,empnum_new
,fname_old
,fname_new
etc...
Thanks,
BOb
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only