Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding a CASE WHEN in a WHERE clause
Message
From
29/07/2015 16:24:27
 
 
To
29/07/2015 16:21:59
Walter Meester
HoogkarspelNetherlands
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2012
Application:
Web
Miscellaneous
Thread ID:
01622652
Message ID:
01622659
Views:
33
>I would rewrite it into a form like
>
>
>UPDATE Client
>	SET DayBetweenFirstAcceptSoldDate = CASE WHEN ....WHEN ... WHEN ... THEN ... ELSE 0 END
>	FROM Client
>		LEFT JOIN BusinessTime ON ....
>		LEFT JOIN Company ON ....
>		LEFT JOIN Research ON ....
>
>
>This will give the optimizer a chance to get you the best performance possible.

Yes, I had that at first but this creates a too long command as I need to repeat pretty much the entire base command. By putting the CASE WHEN inside the WHERE clause, this allows to keep the core of the command as is but only to add an exception down below.
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
Next
Reply
Map
View

Click here to load this message in the networking platform