Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Self join challenge..
Message
From
06/03/2003 15:22:36
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Self join challenge..
Miscellaneous
Thread ID:
00762414
Message ID:
00762414
Views:
53
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
Map
View

Click here to load this message in the networking platform