Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Simplifying WHERE clause with CASE WHEN
Message
From
21/04/2015 14:07:08
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Simplifying WHERE clause with CASE WHEN
Environment versions
SQL Server:
SQL Server 2012
Application:
Web
Miscellaneous
Thread ID:
01618887
Message ID:
01618887
Views:
40
I have a big update command containing a WHERE clause which will take the value from a select but with a condition:
...
     WHERE BusinessTime.NoProvince=
      CASE
       WHEN (SELECT Company.NoCountry FROM Company WHERE Company.Numero=Client.NoCompany)=1 THEN
       (SELECT Company.NoProvince FROM Company WHERE Company.Numero=Client.Company) ELSE 84
       END AND
      BusinessTime.NoHoliday=0 AND
      BusinessTime.Start<Client.FirstDate AND
      BusinessTime.[End]>=Client.SecondDate) Temp)
...
Is there a way to avoid doing two select in the company table to satisfy that need?
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
Next
Reply
Map
View

Click here to load this message in the networking platform