Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CASE WHEN with condition on select value
Message
De
13/04/2015 17:38:59
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
CASE WHEN with condition on select value
Versions des environnements
SQL Server:
SQL Server 2012
Application:
Web
Divers
Thread ID:
01618336
Message ID:
01618336
Vues:
58
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform