Information générale
Forum:
Microsoft SQL Server
Titre:
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
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement