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

Query Help 1

Status
Not open for further replies.

egobbitz

Programmer
Oct 18, 2002
47
US
I am trying to write a query that will return the records in my table based on the date, or set of dates I enter. In this query, I am trying to count the number of records where the process type = 1, and then count the records where the process type = 2, and then count the records where the process type = 3.

I am not sure how to do this well, and so have been monkeying around with a union query, just to get started.

Here is the query I wrote so far, and when I try to add any other fields to the query, I get an error about the item is not used in an aggregate function. Can someone help me?

Code:
select count(*) from tblEntries as Type1
where [ProcessType] = "1"

union

select count(*) from tblEntries as Type2
where [ProcessType] = "2"

UNION select count(*) from tblEntries as Type3
where [ProcessType] = "3";

The table is just an entry table that stores sorter statistics based on process type and date.

Thanks in advance.

Nick
 
select [ProcessType]
, count(*)
from tblEntries
group
by [ProcessType]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top