Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Selecting the top average score with top voters

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2000-08-22 : 22:16:58
Ascii255 writes "I have a page in my site in which users can rate a spesific articles with points 2,1,0,-1,-2. When a user votes, his/her vote is added directly to a column called total votes, and the number of voters is incremented by one. There is an another page which lists the most liked articles. What I am trying to do is

selecting the top average (totalvotes/voters) with top voters

The rest of the question is (What I mean is if 2 articles both have 1.8 and if one has been voted by 2 people and one has been voted by 28 people, the second one should be the top one.)
I tried

select top 5 (totalvotes/voters) from TB_Articles

but it didnt give me the result I wanted. (the first one in the example was above the second one)
so I added an order by clause

select top 5 (totalvotes/voters) from TB_Articles order by - voters

but still it did not give the result I wanted. I'd be glad if you could help. Thanks. (I am using sql server 7, wi
   

- Advertisement -