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

Hopefully simple transact question

Status
Not open for further replies.
Jun 23, 2007
6
US
I have a one column table with 65,000 records comprised of office numbers. In some cases an office number may be listed thirty or forty times, while in other cases an office number may only be listed once or twice. I would like to be able to do a count on DISTINCT office numbers and then display only the TOP 100 office numbers. I've tried several different things without success. Can someone point this novice in the correct direction please? THANKS IN ADVANCE!!!!
 
Try these.

Code:
Select Distinct Top 100
       ColumnName
From   TableName
Order BY ColumnName

Code:
Select Count(Distinct ColumnName) 
From   TableName

Code:
Select ColumnName, Count(*) As TheCount
From   TableName
Group By ColumnName
Order By ColumnName

If you have any questions, please ask.

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top