I have a number of tables that need to be joined to gether and up to now everything has been fine. I now need to exclude old files that are identified by a sequence number; newer records have a higher number.
The joins currently look like this:
Expand|Select|Wrap|Line Numbers
- FROM a
- INNER JOIN b
- ON(a.resource_id = b.resource_id)
- INNER JOIN c
- ON(a.resource_id = c.apar_id)
- INNER JOIN d
- ON(a.client = d.client)
- INNER JOIN e
- ON( a.resource_id = e.resource_id
- AND a.client = e.client )
For Example:
With a.resource_id = 123456
Record 1 (To be excluded due to Record 2):
b.resource_id = 123456
b.sequence_no = 1
Record 2 (To be returned):
b.resource_id = 123456
b.sequence_no = 2
Whereas for records with no superceeding sequence_no:
With a.resource_id = 654321
Record 1 (To be returned):
b.resource_id = 654321
b.sequence_no = 1
I hope that makes sense.
All help is much appreciated.