Jump to content


Photo

Sorting by row value occurrence


  • Please log in to reply
2 replies to this topic

#1 akufen

akufen
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 18 September 2006 - 12:46 PM

Hi

I have a association table - rel_movie_rating - which has the columns movie_id and rating_id. How can I form a query which returns the most frequent movie_id's in the table?

Thanks!

#2 shoz

shoz
  • Staff Alumni
  • Advanced Member
  • 600 posts

Posted 18 September 2006 - 01:02 PM

SELECT movie_id, COUNT(*) AS num FROM table GROUP BY movie_id ORDER BY num


#3 akufen

akufen
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 18 September 2006 - 01:18 PM

Many thanks, this made my day.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users