Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to avoid subs() on left side of equal
Message
De
16/11/2009 11:26:43
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01434947
Message ID:
01434959
Vues:
39
A bit exotic ?

>
>The other way would be a left join with itself and a like condition, e.g.
>
>;with cte_ToExclude as (select IDField 
>from dbo.Meetings (nolock) 
>where iscancelled=0
>and roomclosed=0
>and isblock=0
>and (scheduledBy like 'TEST%'  
>OR scheduledBy like 'CQI%'))
>
>select min(M.sDateTime) as FirstDate 
>from dbo.Meetings (nolock) M
>where M.iscancelled=0
>and M.roomclosed=0
>and M.isblock=0 LEFT JOIN cte_ToExclude C on M.IdField = C.IDField where c.IDField IS NULL
>
>
>Or use not exist condition here:
>select min(M.sDateTime) as FirstDatefrom dbo.Meetings (nolock) M
>where M.iscancelled=0
>and M.roomclosed=0
>and not exists(select 1 from 
>from dbo.Meetings (nolock)  M2
>where M2.iscancelled=0
>and M2.roomclosed=0
>and M2.isblock=0
>and M2.scheduledBy like 'TEST%'  and M2.IdField = M1.IDField) and not exists (select 1 from 
>from dbo.Meetings (nolock)  M3
>where M3.iscancelled=0
>and M3.roomclosed=0
>and M3.isblock=0
>and M3.scheduledBy like 'CQl%'  and M3.IdField = M1.IDField)
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform