Solved

SQL Case When with embedded "or' conditions

Posted on 2015-01-11
2
108 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

[Webinar] Disaster Recovery and Cloud Management

Learn from Unigma and CloudBerry industry veterans which providers are best for certain use cases and how to lower cloud costs, how to grow your Managed Services practice in IaaS clouds, and how to utilize public cloud for Disaster Recovery

Question has a verified solution.

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

I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

867 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now