Select Statement inside a case statement

Database

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

Tags (4)
2 REPLIES
Enthusiast

Re: Select Statement inside a case statement

Hi Raghav,

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

Thanks

Jugal

Senior Apprentice

Re: Select Statement inside a case statement

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