Hi! Could we please enable some services and cookies to improve your experience and our website?
Privacy & Cookie Policy.Hey there!
If sqltest.online has ever helped you learn SQL, practice for an interview, or just satisfy your curiosity. I'd love to hear about it.
This project is something I built and maintain on my own, completely free, because I believe SQL skills should be accessible to everyone. No subscriptions, no paywalls. Just a tool I genuinely enjoy making better.
If you've found it useful, the best thing you can do is share your honest opinion:
And if you do post, please send me the link at ✉️ rozhnev@gmail.com. I'd love to read it and say thank you personally.
❤️ Thank you for using sqltest.online. You're the reason it keeps going.
Slava Rozhnev, creator of sqltest.online
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).
Use PostgreSQL syntax to write your answer. Descriptions of tables are provided in the right pane.
Write your request in the field below and click the "Check it!" button.
ER diagram of the Bookings database
| aircraft_code | model | range | |
|---|---|---|---|
| 1 | 773 | {"en": "Boeing 777-300", "ru": "Боинг 777-300"} | 11100 |
| airport_code | airport_name | city | coordinates | timezone | |
|---|---|---|---|---|---|
| 1 | YKS | {"en": "Yakutsk Airport", "ru": "Якутск"} | {"en": "Yakutsk", "ru": "Якутск"} | (129.77099609375,62.0932998657227) | Asia/Yakutsk |
| ticket_no | flight_id | boarding_no | seat_no | |
|---|---|---|---|---|
| 1 | 0005435212351 | 30625 | 1 | 2D |
| book_ref | book_date | total_amount | |
|---|---|---|---|
| 1 | 00000F | 2017-07-05 00:12:00+00 | 265700.00 |
| flight_id | flight_no | scheduled_departure | scheduled_arrival | departure_airport | arrival_airport | status | aircraft_code | actual_departure | actual_arrival | |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1185 | PG0134 | 2017-09-10 06:50:00+00 | 2017-09-10 11:55:00+00 | DME | BTK | Scheduled | 319 |
| aircraft_code | seat_no | fare_conditions | |
|---|---|---|---|
| 1 | 319 | 2A | Business |
| ticket_no | flight_id | fare_conditions | amount | |
|---|---|---|---|---|
| 1 | 0005432159776 | 30625 | Business | 42100.00 |
| ticket_no | book_ref | passenger_id | passenger_name | contact_data | |
|---|---|---|---|---|---|
| 1 | 0005432000987 | 06B046 | 8149 604011 | VALERIY TIKHONOV | {"phone": "+70127117011"} |