I need an SQL Statement or some type of proceedure to "count"
Category: Computers > Programming
Asked by: stevenclary-ga
List Price: $10.00
02 Feb 2005 10:26 PST
Expires: 04 Mar 2005 10:26 PST
Question ID: 467616
I have a very simple access database (table) with 2 columns ( USERNAME & DEPARTMENT). There are about 4 dozen rows. I would like to create a report/view/etc that will give me a count of the each distinct departments. The departments may change in the main table.
Re: I need an SQL Statement or some type of proceedure to "count"
Answered By: tox-ga on 02 Feb 2005 10:44 PST
stevenclary-ga The SQL statement you are looking for is as follows: SELECT DEPARTMENT, COUNT(DEPARTMENT) AS [DEPARTMENT COUNT] FROM [table] GROUP BY DEPARTMENT You should replace table with the actual table name and DEPARTMENT COUNT with the preferred column name for the count. To create a view, use the following script, replacing VIEW NAME with the desired viewname: CREATE VIEW dbo.[VIEW NAME] AS SELECT DEPARTMENT, COUNT(DEPARTMENT) AS [DEPARTMENT COUNT] FROM [table] GROUP BY DEPARTMENT If you have any questions, feel free to ask for clarification. Cheers, tox-ga
rated this answer:
Thanks so much!
|There are no comments at this time.|
If you feel that you have found inappropriate content, please let us know by emailing us at email@example.com with the question ID listed above. Thank you.
|Search Google Answers for|