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

Count rows in Query 1

Status
Not open for further replies.

JPimp

Technical User
Mar 27, 2007
79
US
For some reason I can count the total rows, if that is all I want, but if I want other fields as well, I receive an error that there is either a mislinked field or no data exists (although I know there is).

This is the query code:

Code:
SELECT DEPARTMENT, COUNT(*) AS TTL FROM WO_WORK_ORDER



Just call me Spunky
 
Hi,
You need to add a GROUP BY statement including any fields requested prior to the aggregate function ( COUNT, SUM, AVG, etc)

In your example it would be:
Code:
SELECT DEPARTMENT, COUNT(*) AS TTL FROM WO_WORK_ORDER
Group By DEPARTMENT

This will give the count in each Department..




[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Awesome!! Thank you so much Turkbear!

Just call me Spunky
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top