Creating a temporary view or table [message #2539] |
Wed, 24 July 2002 12:42 |
Johnny Whiplash
Messages: 7 Registered: May 2002
|
Junior Member |
|
|
I'm trying to create a query that not only give me the names of a particular column, but also give me the count for each distinct record. My pseudo code is as follows:
CREATE VIEW TEMP AS
(SELECT NAME FROM DBO.TABLE1 A, DBO.TABLE2 B
WHERE A.ID = B.GROUPID
AND
B.GROUPID IN
(SELECT GROUPID FROM DBO TABLE2)
Then count the records for each name with a count per name. So I want my results to be something like:
NAME COUNT
NAME COUNT
NAME COUNT
Any suggestions would be great. Thanks.
|
|
|
Re: Creating a temporary view or table [message #2540 is a reply to message #2539] |
Wed, 24 July 2002 12:59 |
Todd Barry
Messages: 4819 Registered: August 2001
|
Senior Member |
|
|
I'm not sure about your view definition (checking that b.groupid is in the list of groupid values from b looks redundant), but once you have a set of names:
select name, count(*)
from temp
group by name;
|
|
|
|
|