I want to have the top cathegory value for each state
SELECT DISTINCT COUNT(tweet_category) AS category_count, tweet_category, tweet_state
FROM [New_years_resolutions_2020]
GROUP BY tweet_state, tweet_category
ORDER BY tweet_state, category_count DESC;
catehgory_count | tweet_cathegory | tweet_state |
---|---|---|
5 | Personal Growth | AK |
4 | Family/Friends | AK |
3 | Health/Fitness | AK |
2 | Humor | AK |
15 | Health/Fitness | AL |
8 | Family/Friends | AL |
6 | Personal Growth | AL |
9 | Humor | AL |
I would like the result to look like:
catehgory_count | tweet_cathegory | tweet_state |
---|---|---|
5 | Personal Growth | AK |
15 | Health/Fitness | AL |