Hi,

Is it possible to have a subquery within a case statement and perform greater than / less than comparisons on the value returned in the subquery?

i.e.

select case (select price from product)
when < 100 then 'cheap'
when < 150 AND > 101 then 'fairly expensive'
else 'expensive';

Sorry for the for example, but you get the idea?

Thanks,
nickj

Recommended Answers

All 3 Replies

couldn't find anything on the MSDN that suggests you can?

Their is no way to control flow with Case in SQL so the easy answer to your question is no it is not possible.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.