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

Help with a query

Status
Not open for further replies.

limester

Technical User
Dec 29, 2004
69
CA
I am trying to query a database where I have tbl1

I would like to count tbl1 and then return the distinct rows of clm1 tbl1.

For example, I have 10,000 entries in tbl1. clm1 represents a state so the output I am looking for is:

2,000 OH
4,000 CA
4,000 FL

Thanks!
 
You'll want to use group by. There are many aggregate functions at your disposal, each requiring a group by. Do a little research in Books On Line.

Code:
Select clm1,
       Count(*) As CountOfRecords
From   tbl1
Group By clm1
Order By clm1

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Thanks gmmastros....I had just found the answer using group by, I swear!! : )

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top