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
 Selection at most 1 row on 2nd table in LEFT JOIN

Author  Topic 

vermorel
Starting Member

26 Posts

Posted - 2006-11-30 : 07:55:27
I have a query that include a single LEFT JOIN. I would like to be able to select at most 1 row of the second table (providing that the JOIN represents a one to many relationship).

Does anyone knows how to do that?
Thanks in advance,
Joannès

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-30 : 07:58:28
1) Derived table
2) Correlated subquery
3) GROUP BY using MIN or MAX



Peter Larsson
Helsingborg, Sweden
Go to Top of Page

vermorel
Starting Member

26 Posts

Posted - 2006-11-30 : 08:30:46
Thanks, GROUP BY + MIN does the trick.

Best regards,
Joannes
Go to Top of Page
   

- Advertisement -