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

using WHERE without excluding

Status
Not open for further replies.

madrappin

Technical User
Mar 16, 2004
68
US
is it possible to have a count function that counts all values that are greater than 2, but rather than excluding the values that are less than 2 from the query, have them show up as zeros?
 
Try
[blue][tt]
Select
IIF ( fld <= 2, "0", ">2" ) As [FieldRange],
Sum ( IIF ( fld <= 2, 1, 0 ) ) As [CountofFields]

From tbl

Group By IIF ( fld <= 2, "0", ">2" )
[/tt][/blue]
will count all the fields greater than 2. You will get 2 records ... one with [FieldRange] = "0" and one with [FieldRange] = ">2" and a count for each.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top