[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

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
0
rcmb
Asked:
rcmb
1 Solution
 
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now