Solved

SQL Case When with embedded "or' conditions

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

705 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

19 Experts available now in Live!

Get 1:1 Help Now