Back to questions
Delve into the Marvel Avengers dataset and write a query to categorize the superheroes based on their average likes as follows:
Display the superhero's character name, platform, average likes, and the corresponding likes category.
|actor||varchar||The name of the actor who portrays the Marvel Avengers character.|
|character||varchar||The name of the Marvel Avengers character.|
|superhero_alias||varchar||The superhero alias or code name of the character.|
|platform||varchar||The social media platform where the character has a presence.|
|followers||integer||The number of followers or subscribers on the character's social media platform.|
|posts||integer||The total number of posts made by the character on the social media platform.|
|engagement_rate||decimal(5,2)||The engagement rate of the character's posts on the social media platform.|
|avg_likes||integer||The average number of likes received on the character's posts.|
|avg_comments||integer||The average number of comments received on the character's posts.|
|Robert Downey Jr.||Tony Stark||Iron Man||500000||200||8.20||12000||800|
|Chris Evans||Steve Rogers||Captain America||300000||150||6.50||8000||500|
|Scarlett Johansson||Natasha Romanoff||Black Widow||700000||300||7.80||15000||1000|
|Mark Ruffalo||Bruce Banner||Hulk||200000||80||5.30||6000||400|
In this step, we define the different categories for likes based on the average number of likes:
In this step, we use the statement to categorize each character based on their average number of likes. The statement evaluates the column for each record and assigns the corresponding likes category based on the defined conditions.
In this final step, we use the clause to sort the result set based on the column in descending order. This means that the characters with the highest average number of likes will appear first in the result set.