Quantcast
Channel: case inside having
Viewing all articles
Browse latest Browse all 8

case inside having

0
0

Hi,
Is it possible to place case inside having clause?
for example:
select field1, field2, sum(field3)
from tblMain
group by field1, field2
having sum(field3) > 0.1

I would like to do something like:
select field1, field2, sum(field3)
from tblMain
group by field1, field2
case when @param=1 then having sum(field3) > 0.1

so only do the having bit when @param = 1
Any thoughts please?
Thanks


Viewing all articles
Browse latest Browse all 8

Latest Images

Trending Articles





Latest Images