Solved

SQL Case When with embedded "or' conditions

Posted on 2015-01-11
2
116 Views
Last Modified: 2015-01-11
I am trying to write a Case When statement with three conditions.  The first two are straight forward.  The third is a Case when with 4 or conditions:

Case when OE.Category = 'PHA' then
                                 case when P.DirectionID = '.STK-MED' then 
                                 [b]case when MOS.ProviderYn = 'Y' then 
                                      when MOS.CosignYn = 'Y' then 
                                      when OE.OrderDateTime = OEOS.SigDateTime then
                                      when DMU.ProviderID = OE.ProviderID[/b] then 1 else 0 end else 0 else 0 end as TotMedCPOE

Open in new window


As you see if the OE.Gategory = "PHA" and the P.DirectionID = '.STK-MED' no problem.  However the third condition can be anyone of 4 to be true.  What is the proper syntax for the last condition?

thanks Glen
0
Comment
Question by:GPSPOW
2 Comments
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40543354
CASE WHEN MOS.ProivderYn = 'Y" or MOS.CosignYN = 'Y' or

etc.
0
 

Author Closing Comment

by:GPSPOW
ID: 40543365
Thank you
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question