Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Self join challenge..
Message
De
06/03/2003 15:22:36
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Self join challenge..
Divers
Thread ID:
00762414
Message ID:
00762414
Vues:
52
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
Fil
Voir

Click here to load this message in the networking platform