Back to questions

SQL Tutorial Lesson: Superheroes' Likes [Marvel's Avengers SQL Interview Question]


Delve into the Marvel Avengers dataset and write a query to categorize the superheroes based on their average likes as follows:

  • Super Likes: Superheroes with an average likes count greater than or equal to 15,000.
  • Good Likes: Superheroes with an average likes count between 5,000 and 14,999 (inclusive).
  • Low Likes: Superheroes with an average likes count less than 5,000.

Display the superhero's character name, platform, average likes, and the corresponding likes category.


Column NameTypeDescription
actorvarcharThe name of the actor who portrays the Marvel Avengers character.
charactervarcharThe name of the Marvel Avengers character.
superhero_aliasvarcharThe superhero alias or code name of the character.
platformvarcharThe social media platform where the character has a presence.
followersintegerThe number of followers or subscribers on the character's social media platform.
postsintegerThe total number of posts made by the character on the social media platform.
engagement_ratedecimal(5,2)The engagement rate of the character's posts on the social media platform.
avg_likesintegerThe average number of likes received on the character's posts.
avg_commentsintegerThe average number of comments received on the character's posts.

Example Input:

Robert Downey Jr.Tony StarkIron ManInstagram5000002008.2012000800
Chris EvansSteve RogersCaptain AmericaTwitter3000001506.508000500
Scarlett JohanssonNatasha RomanoffBlack WidowInstagram7000003007.80150001000
Chris HemsworthThorThorYouTube4000001009.10200001200
Mark RuffaloBruce BannerHulkTwitter200000805.306000400

PostgreSQL 14