Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding a CASE WHEN in a WHERE clause
Message
From
30/07/2015 09:07:29
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2012
Application:
Web
Miscellaneous
Thread ID:
01622652
Message ID:
01622686
Views:
30
>Start from this query:
>
>
>;with cte as (select Client.*, COALESCE(Company.NoProvince, 84) as NoProvince 
>from Client LEFT JOIN Company ON Client.NoCompany = Company.Numero and Company.NoCountry = 1
>WHERE Client.FirstAcceptDate>'1899-12-30 00:00:00.000' AND
>    Client.QueryDate>'1899-12-30 00:00:00.000' AND
>    Client.QueryDate>=Client.FirstAcceptDate AND
>    Client.NoCompany>0
>UNION ALL
>select Client.*, COALESCE(Research.NoProvince, 84) as NoProvince 
>from Client LEFT JOIN Research ON Client.NoReseach = Research.Numero and Research.NoCountry = 1
>WHERE Client.FirstAcceptDate>'1899-12-30 00:00:00.000' AND
>    Client.QueryDate>'1899-12-30 00:00:00.000' AND
>    Client.QueryDate>=Client.FirstAcceptDate AND
>    Client.NoResearch>0)
>
>select * from cte
>
>This is what you're going to join with the sum of the BusinessTime.

Thanks
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform