Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to avoid subs() on left side of equal
Message
From
16/11/2009 11:26:43
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01434947
Message ID:
01434959
Views:
38
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform