View Single Post
  #2 (permalink)  
Old 04-30-2007, 01:58 PM
ben ben is offline
Administrator
 
Join Date: Mar 2007
Posts: 93
ben has disabled reputation
Default ANY answer. Re: The top x most popular whatever?

The x most popular ever would be something along the lines:

[sql]SELECT t1.name, sum(t2.voteValue) as totalVotes FROM photo as t1
INNER JOIN photo_has_rating as t2 ON t2.pid = t1.pid
GROUP BY t2.voteValue
ORDER BY totalVotes
LIMIT x[/sql]

If you wanted the the result for the last week you would have to use a WHERE clause
Reply With Quote