Google Answers Logo
View Question
 
Q: I need an SQL Statement or some type of proceedure to "count" ( Answered 5 out of 5 stars,   0 Comments )
Question  
Subject: I need an SQL Statement or some type of proceedure to "count"
Category: Computers > Programming
Asked by: stevenclary-ga
List Price: $10.00
Posted: 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.
Answer  
Subject: Re: I need an SQL Statement or some type of proceedure to "count"
Answered By: tox-ga on 02 Feb 2005 10:44 PST
Rated:5 out of 5 stars
 
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
stevenclary-ga rated this answer:5 out of 5 stars
Thanks so much!

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy