COUNT RECORDS

Hello experts,

I have a SQL 2K table similar to the following

BallotId      EnteredBy       Vote1          Vote2        Vote3
1              User1              191             312           415
2              User2              193             315           412
3              User3              191             312           455
4              User4              191             333           412
5              User5              193             312           415
6              User6              189             311           455
7              User7              191             312           455
8              User8              193             322           415

The numbers in my example mean nothing other than for illustration purpose.

What I need to determine is the number of times each number appears in a field and order them by the count from that field. Basically I need to know for column Vote1, Vote2, etc.

So my return would look like:
Count   Vote1
4          191
3          193
1          189

I am return this to an asp page and I want them seperately. What I am doing is conducting an online vote of women's fastpitch and they will vote on Coach of the Year, Pitcher of the Year, etc and I need to count the votes and return the information to the user.

Hope this makes sense.

Curtis
LVL 12
rcmbAsked:
Who is Participating?
 
Anthony PerkinsCommented:
Select Count(*) [Count], Vote1
From YourTableName
Group By Vote1
Order By 1 DESC
 
0
 
rcmbAuthor Commented:
Thanks for the quick response. Works like a charm.

Curtis
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.