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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Count? 2

Status
Not open for further replies.

tlove161

Technical User
Feb 5, 2004
42
0
0
US
Hello

I have a simple question that has me stumped. I have a two column table, [EVENT_ID], [OUTCOME]. [OUTCOME] has "yes" or "no" values. Is it possible to count both the yes and no is one query? Thank you.
 
SELECT Count(IIf([OUTCOME]="yes",1,0)) As [Yes],Count(IIf([OUTCOME]="no",1,0)) As [No]
FROM yourTable

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,
You are usually so invincible. Surely you meant to use Sum(...) rather than Count(...).
SELECT Sum(IIf([OUTCOME]="yes",1,0)) As [Yes], Sum(IIf([OUTCOME]="no",1,0)) As [No]
FROM yourTable

or
SELECT Sum(Abs([OUTCOME]="yes")) As [Yes], Sum(Abs([OUTCOME]="no")) As [No]
FROM yourTable

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Duane, thanks for the nice words and for the correction.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top