Basically I have a flat table that contains contact details AND order details (I didn't make it .. just inherited it)
The pkey is a auto-incrementing field, what I need to do is get what the "previous" id is for a given contact, null if there was no preivous.
sample data:
RecID ContactID
6000 100
6500 100
7000 100
What I need the output to look like is:
PreviousRecID RecID ContactID
NULL 6000 100
6000 6500 100
6500 7000 100
This should be a pretty easy self join ... but I'll go ahead and blame my allergy meds on this one
Thanks in advance
The pkey is a auto-incrementing field, what I need to do is get what the "previous" id is for a given contact, null if there was no preivous.
sample data:
RecID ContactID
6000 100
6500 100
7000 100
What I need the output to look like is:
PreviousRecID RecID ContactID
NULL 6000 100
6000 6500 100
6500 7000 100
This should be a pretty easy self join ... but I'll go ahead and blame my allergy meds on this one
Thanks in advance