Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CASE WHEN with condition on select value
Message
From
13/04/2015 17:38:59
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Other
Title:
CASE WHEN with condition on select value
Environment versions
SQL Server:
SQL Server 2012
Application:
Web
Miscellaneous
Thread ID:
01618336
Message ID:
01618336
Views:
59
I have a CASE WHEN condition I need to implement based on the select value.

Lets say I have this:
UPDATE Client
 SET NoProvince=
  CASE
   WHEN (SELECT COALESCE((SELECT TOP 1 Invoice.AddUser FROM Invoice
    WHERE Invoice.NoClient=Client.Numero AND Invoice.NoItem=23
    ORDER BY Invoice.AI DESC),0))<>1 THEN AddUser ELSE 0
  END
Basically, I need to select the most recent record in the invoice table based on NoItem=23 condition. Then, based on the value collected, in this case Invoice.AddUser, I need to have a sub condition to only replace Client.NoProvince if Invoice.AddUser value is not 1.

How can I fine tune this update to support this?
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