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
 General SQL Server Forums
 New to SQL Server Programming
 SQL Join 3 tables getting rows repeating

Author  Topic 

jrosser
Starting Member

14 Posts

Posted - 2014-01-27 : 11:06:48
I am using three tables/view.

The first is a vendor table where I am pulling company/ID/name

I am using a left join to the other two tables on company/ID

The problem I am having is if the second table has 8 rows and the third table just has 1 row it will repeat 8 times.

How do I show all 8 from the second table but only the 1 from the third table?

You can see below that the voucher number and amount repeat

vendor_id vendor_name po_no po_amount voucher_no amount_due
36999 VITEK 6012838 $174.00 2622666 $(1,791.00)
36999 VITEK 6016464 $822.90 2622666 $(1,791.00)
36999 VITEK 6017791 $876.00 2622666 $(1,791.00)
36999 VITEK 6025495 $600.00 2622666 $(1,791.00)
36999 VITEK 6029781 $930.00 2622666 $(1,791.00)
36999 VITEK 6034433 $3,264.00 2622666 $(1,791.00)
36999 VITEK 6037821 $2,715.00 2622666 $(1,791.00)



Jeremy Rosser

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2014-01-27 : 13:52:09
>>How do I show all 8 from the second table but only the 1 from the third table?
Can you post a sample of how you want this to appear?

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -