Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Nested join

Author  Topic 

jung1975
Aged Yak Warrior

503 Posts

Posted - 2003-03-26 : 16:27:35
I have a following DDL.

SELECT clm_clmt, a.ref_company as Plattorney ,b.ref_company as Defattorney,xref_totinc as totincur
FROM claim
INNER JOIN clmref ON claim.claim_key=clmref.cref_claim
LEFT JOIN refinfo as a ON clmref.cref_ref = a.ref_key AND a.ref_type='<Attorney - Defense>'
LEFT JOIN refinfo as b ON clmref.cref_ref = b.ref_key AND b.ref_type='<Attorney - Plaintiff>'
order by clm_clmt.

The Output is
Clm_clmt Plattorney Defattorney totincur

John ABC NULL 1300.00
John NULL DEF 1300.00
John ABC NULL 1300.00

But, I would like to get the output looks like: ( shows plattorney and Defattorney in one line)

Clm_clmt Plattorney Defattorney totincur
John ABC DEF 1300.00


Any help would be appreciated..

Thank you

X002548
Not Just a Number

15586 Posts

Posted - 2003-03-26 : 16:50:28
First, it's DML, and Second I think you've got a cartesin product going on. When you join claim to claimref ON claim_key=cref_claim, how many rows do you get? Do that join first and let us know.

Now would be a good time to discuss DDL (The stuff that builds your tables). If you could post that (with Contraints, ect) that would help.


Brett

8-)

Edited by - x002548 on 03/26/2003 16:51:33
Go to Top of Page
   

- Advertisement -