Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Simplifying WHERE clause with CASE WHEN
Message
De
21/04/2015 14:07:08
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Simplifying WHERE clause with CASE WHEN
Versions des environnements
SQL Server:
SQL Server 2012
Application:
Web
Divers
Thread ID:
01618887
Message ID:
01618887
Vues:
38
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform