eo
MIS
- Apr 3, 2003
- 809
Hi,
I have a table with Policy Numbers, this links to a PolicyNumberLink table that holds an audit trail of those policy numbers, and states previous Policy Numbers and new Policy Numbers. By calling a particular Policy Number, I am hoping there is a way to return all its predecessors. I will try and explain by example:
Policy numbers can move from business system 1 to 2 to 3, and gets a new policy number of every new business system:
If I want to select the current PolicyNymber...
...how do I return all its predecessors?
Bu using a self referencing join on the PolicyNumberLinkTable from PrevPolicyNumber join PolicyNumber I am sure I can return the PolicyNumber 2002001, but I think the PolicyNumber 1001001 will be ignored
Any ideas
I work with SQL Server 2005 btw
EO
Hertfordshire, England
I have a table with Policy Numbers, this links to a PolicyNumberLink table that holds an audit trail of those policy numbers, and states previous Policy Numbers and new Policy Numbers. By calling a particular Policy Number, I am hoping there is a way to return all its predecessors. I will try and explain by example:
Policy numbers can move from business system 1 to 2 to 3, and gets a new policy number of every new business system:
Code:
The PolicyNumbers as they move between BusinessSystems:
BusinessSystem1 > BusinessSystem2 > BusinessSystem3
1001001 > 2002001 > 3003001
These records are written to the Policy table:
PolicyTable:
Date PolicyNumber
==== ============
01/01/2006 1001001
01/01/2007 2002001
01/01/2008 3003001
A PolicyNumber link table shows the audit trial:
PolicyNumberLinkTable:
PolicyNumber PrevPolicyNumber NewPolicyNumber
============ ================ ===============
1001001 1001001 2002001
2002001 1001001 3003001
3003001 2002001 NULL
If I want to select the current PolicyNymber...
Code:
where PolicyNumberLinkTable.PolicyNumber = 3003001
Bu using a self referencing join on the PolicyNumberLinkTable from PrevPolicyNumber join PolicyNumber I am sure I can return the PolicyNumber 2002001, but I think the PolicyNumber 1001001 will be ignored
Any ideas
I work with SQL Server 2005 btw
EO
Hertfordshire, England