Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
One to many relationship INNER JOIN condition
Message
 
 
To
14/02/2011 13:58:04
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01500073
Message ID:
01500138
Views:
44
>>Try this (suggested by Peter Larsson):
>>
>>
>>SELECT                   m.Numero
>>FROM                     dbo.ChildTable AS c
>>LEFT JOIN   dbo.ManyToManyTable AS mm ON mm.NoChildTable = c.Numero
>>LEFT JOIN   dbo.[Master] AS m ON m.Numero = mm.NoMaster
>>GROUP BY    m.Numero
>>HAVING                   COUNT(c.Numero) <= COUNT(m.Numero)
>>                         AND MIN(CASE WHEN c.[Enabled] = 1 THEN 1 ELSE 0 END) = 1
>
>Thanks, that works.

Interesting. BTW, I hope Peter is going to join UT soon as he just asked me to provide a link to this thread.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform