Avatar of garethtnash
garethtnash
Flag for United Kingdom of Great Britain and Northern Ireland asked on

CASE IS NULL

Hello,

My select statement isn't workin, when the value returned is NULL i see nothing...

Select TOP(1)
CASE 
WHEN O.OrderDate IS NULL THEN 'Yet to Order'
Else O.OrderDate 
END 
AS LastOrderDate
From dbo.Ordertb O
Where O.MemberID = 1

Open in new window


Please advise

Thank you
Microsoft SQL Server 2008Microsoft SQL Server 2005Microsoft SQL Server

Avatar of undefined
Last Comment
Qlemo

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Guy Hengel [angelIII / a3]

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
crisco96

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
garethtnash

ASKER
Thank you both
Qlemo

I agree. In that case it is safe to assume empty strings and NULLS are the same, and so I would substitute them for each other, e.g.
select top 1
  case when IsNull(O.OrderDate, '') = '' then 'Yet to Order'
    else O.OrderDate
  end as LastOrderDate
from dbo.Ordertb O
where O.MemberID = 1

Open in new window

but that doesn't make any difference.
Your help has saved me hundreds of hours of internet surfing.
fblack61