All Forums Database
raghav.garg 2 posts Joined 09/14
25 Sep 2014
Select Statement inside a case statement

Hello,
 
I am facing a problem when writing a case statement, 
Here is the sample query

Case when (select count(*)from ABC) >'0' then 'Data is available' else 'No data' end

It is giving me a syntax error '3706: Expected something between > and '0'.
Can someone please suggest what I am doing wrong here.
 
Thanks
Raghav

25 Sep 2014

Hi Raghav,
The above case statement looks fine. If would give the result as 'Data is Available' if the count(*) > 0.
 
 
Thanks
Jugal

dnoeth 4628 posts Joined 11/04
25 Sep 2014

Hi Raghav,
do you try to run this as a standalone query?

select Case when (select count(*)from ABC) >'0' then 'Data is available' else 'No data' end

or better

select Case when count(*) >'0' then 'Data is available' else 'No data' end
from ABC

 
 

Dieter

You must sign in to leave a comment.