# Related Sites > SQL Course >  iif in sql server

## kaur_gurpreet

I have the Following Data in the Following Table: Tb1

Name	NameType	Sale
A	a		100		
B	a		200		
C	a		300
D	b		400
E	b		500
F	b		600

The Following Query Works in MsAccess

select sum(sale), nametype 
from tb1 
group by nametype
having iif(nametype='a',sum(sale)>500,sum(sale)>2000)

How Can I Substitute this For SqlServer.

----------


## skhanal

There is no equivalent of IIF for HAVING clause. CASE is the closest thing you have but it will not work for your query.

----------


## kaur_gurpreet

i got the solution. this is just for your update:

Select 
   Sum(Sale), 
   NameType 
From 
   tb1 
Group By 
   NameType 
Having 
   Sum(Sale) > Case NameType When 'a' Then 500 Else 2000 End

----------

