Reputation: 241
I am using mysql. I have one table called flow_data There is two attributes category and views. category is int type and views is int type. category has 0-4(for example num 0 is video and num 1 is pics) and numbers of view is based on how many times users click. I want to query data that top5 views for each category.
SELECT DISTINCT id, cat, title, file, type, tags
FROM flow_data
ORDER BY views
LIMIT 5
It only returns top5 views not based on each category.
Any thought? Thank you advance.
Upvotes: 0
Views: 422
Reputation: 8199
There is rank query in oracle and sql server you may search for rank equivalent in mysql. You may see here. You may also see this and this also
Upvotes: 2