⏳ Last days of October! SQLtest.online is free thanks to donations, and we still need to reach this month's goal to keep the site running in November. Every donation counts. Support now →
SQL code copied to buffer
Task 46:

Name Popularity Classification

PostgreSQL
Analyze passenger data to classify first names by popularity. The passenger_name column in the tickets table contains full names with first and last name divided by a space.
Extract the passenger's first names, count the occurrences of each first name and classify names into 3 popularity groups: Most Popular, Moderately Popular, and Least Popular

Output results in the table with next columns:
- first_name - extracted first name in uppercase
- occurrences_count - number of the name occurrences
- popularity - popularity classification (Most Popular, Moderately Popular, or Least Popular)
sorted by popularity count (descending), then by first name (alphabetically).
Expected result Columns: 3 · Rows: 363
first_name occurrences_count popularity

Sample rows open after wrong checks: 0 of 3

Write your query below and click "Check it!". Tables are described in the right pane.

Tutorial
The query result will appear here. Ctrl+Enter - Run query