Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
CASE WHEN based on select
Message
De
13/04/2015 11:47:27
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
CASE WHEN based on select
Versions des environnements
SQL Server:
SQL Server 2012
Application:
Web
Divers
Thread ID:
01618310
Message ID:
01618310
Vues:
38
I have a case when syntax which should be based on a select.

For example, this is a simple syntax:
UPDATE Client
 SET NoType=
  CASE
  WHEN Client.NoCompany=0 AND Client.NoProvince>0 THEN 1
  WHEN Client.NoCompany>0 THEN 2 
  END
Now, I need the second condition to be based on a select such as:
UPDATE Client
 SET NoType=
  CASE
  WHEN Client.NoCompany=0 AND Client.NoProvince>0 THEN 1
  WHEN Client.NoCompany>0 THEN (SELECT Company.Activated FROM Company WHERE Company.Numero=Client.NoCompany)=3 
  END
What has to be adjusted is that if the select has Company.Activated=True, I need to obtain 2. If it is False, I need to obtain 3.

How can this syntax be adjusted?
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