Counting

haydenal

Registered User.
Local time
Today, 13:32
Joined
Jan 8, 2009
Messages
52
I have a query that includes [NAME], [INCIDENT] and [CLASS]. Can anyone show me an example of doing a query that would give me a count of unique incidents by unique name? For example, my data might look like this:

NAME INCIDENT CLASS
TIM 1 x
TIM 1 y
TIM 1 z
TIM 2 x
BILL 3 a
TED 1 b

I'm trying to find TIM = 2, BILL = 1 and TED = 1
 
I have a query that includes [NAME], [INCIDENT] and [CLASS]. Can anyone show me an example of doing a query that would give me a count of unique incidents by unique name? For example, my data might look like this:

NAME INCIDENT CLASS
TIM 1 x
TIM 1 y
TIM 1 z
TIM 2 x
BILL 3 a
TED 1 b

I'm trying to find TIM = 2, BILL = 1 and TED = 1

I would think Tim should = 4 not 2. Which is correct?


You could use a totaling query that groupo n [NAME] (note that NAME is a reserved word and should not be used for user named objects). I would count the primary key field
 
I think it is 2 Boyd, as that's the number of unique incidents (1 and 2). I do agree about the reserved words. I'm not the best with SQL, but try something like this:

SELECT Alias.NAME, Count(Alias.NAME) AS HowMany
FROM
(SELECT NAME, INCIDENT
FROM TableName
GROUP BY NAME, INCIDENT) AS Alias
GROUP BY Alias.NAME
 
Tim should equal 2 (1 and 2).

I'll give the SQL and [NAME] suggestions a shot on Friday. Thanks gents!
 
Last edited:
No problem; glad it worked. It looked a little clunky, but I thought it should work.
 

Users who are viewing this thread

Back
Top Bottom