[thelist] SQL Query to count votes and order by highest

Chris Byrd chris.byrd at openhosting.co.uk
Sat Dec 2 13:01:27 CST 2006

Hi All
I've got in a bit of a muddle with an SQL query
I'm part way through creating an online voting system for various school
'awards' and I need a query to count the number of votes for a specific
'award' and list the results in descending order 
Each time there's a vote, a row is created in a 'vote' table
Amongst other fields in the 'vote' table are 'vote_to_student_id' and
Basically, I need to be able to run a query for each 'award_id' that
will return (in descending order) the number of votes and each
corresponding vote_to_student_id
Hopefully this makes sense
I've got access to all the features of MS SQL Server 2000

Can anyone help me out? I've been at this for hours and just keep going
round in circles. Plus, I think it's a little over my head! I'll be
eternally grateful
Thanks in advance!

More information about the thelist mailing list