Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simplify my query 1

Status
Not open for further replies.

nnuswantari

Programmer
Nov 21, 2009
17
ID
I have query as bellow:
Code:
select a,b,
sum(iif(c=1 or c=3 or c=5 or c=8 or c=9 or c=12 or c=14,1,0)) as k3, 
sum(iif(c=2 or c=3 or c=6 or c=7 or c=10 or c=11 or c=14 or c=15 or c=18,1,0)) as k4 
from tabelA
group by a,b;

Can make this query so simple?
 
Like this ?
Code:
SELECT a, b
, SUM(IIf(c IN(1,3,5,8,9,12,14),1,0)) AS k3
, SUM(IIf(c IN(2,3,6,7,10,11,14,15,18),1,0)) AS k4
FROM tabelA
GROUP BY a,b;

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top