Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quick Question

Status
Not open for further replies.

mlager

Programmer
Sep 1, 2006
74
US
What's the best way to handle the following scenario in SQL Server 2005?

I have a table with claims in it that get transferred from one entity to the next, sometimes once, sometimes 10 times. The table has the following format. My goal is to group all the claims with their INITIAL claim (ParentClaimRef = 0). I can back track to the INITIAL claim using the ParentClaimRef, but am not sure how to write a query to do this automaticlly.

ClaimRef ParentClaimRef ClaimNumber
-------- -------------- -----------
35945 0 15517
35946 35945 15518
35947 35946 15519

Ideally, I'd like to end up with a result set that looks like this:

ClaimRef ParentClaimRef ClaimNumber InitialClaim
-------- -------------- ----------- ------------
35945 0 15517 15517
35946 35945 15518 15517
35947 35946 15519 15517

Any suggestions would be greatly appreciated! Thanks.

Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top