Jump to content

Archived

This topic is now archived and is closed to further replies.

akufen

Sorting by row value occurrence

Recommended Posts

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!

Share this post


Link to post
Share on other sites
[code]
SELECT movie_id, COUNT(*) AS num FROM table GROUP BY movie_id ORDER BY num
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.