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
 Transact-SQL (2000)
 Help with join.

Author  Topic 

tpayne
Starting Member

18 Posts

Posted - 2009-08-18 : 16:21:34
I have two tables Master and Detail joined by a key. I need a query to return all the detail records that match the master key even if they are duplicates.
I thought this would be easy like this.
select count(*)
form Detail D
Join Master M on E.key = M.key

This doesn't seem to return the duplicate Detail records though.

I thought about using left join but that return all detail regardless of a match in Master. Thanks in advance.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-08-18 : 16:29:33
SELECT m.key,
count(d.*)
from Master as M
left join Detail as D on d.key = M.key
group by m.key



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -