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

Get count of total numbers over a value 1

Status
Not open for further replies.

dreampolice

Technical User
Dec 20, 2006
85
US
I am trying to fetch total number of values in a column that are greater than 1 in my Access 2004.

For example the below would show that fieldOne has 1 value greater than the value 1 and fieldTwo has 2 values greater than the value 1:
Code:
fieldOne    fieldTwo
1           3
2           1
1           3

The below is not working because it only fetches the first one (fieldOne) that has values over 1.
Code:
select count(fieldOne) as myTot,
count(fieldTwo) as myTot2
from theTable
where
fieldOne > 1
or
fieldTwo > 1

 
Try this SQL:
Code:
Select Sum(Abs([FieldOne]>1)) as CountOne,
Sum(Abs([FieldTwo]>1)) as CountTwo
FROM theTable;

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]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top