Hotel guests from nested JSON
Hotel guests from nested JSON
You work at the SunTrail tour operator. A partner booking system sends every reservation as a JSONB payload: a guest object with the guest name, holding a nested contact object with city and email. The guest-care team needs a list of guests with their cities to send regional arrival guides.
Some bookings arrive without the contact block — include those guests too, just without a city.
Return columns:
- booking_id — booking number (integer);
- hotel — hotel name (a regular table column);
- guest_name — the guest name from guest.name, as text;
- guest_city — the city from guest.contact.city, as text; NULL when the contact or the city is absent.
Sort by booking_id ascending. One row per booking, no filtering.
Exemplo de resposta esperada
É assim que se parece uma resposta correta: ela tem seu próprio número de linhas e não precisa coincidir com as tabelas do esquema. Sua resposta precisa retornar os mesmos nomes de colunas do exemplo: use AS para renomeá-las se for preciso.
| booking_id | hotel | guest_name | guest_city |
|---|---|---|---|
| 1 | Palm Bay Resort | Alice Roy | Lyon |
| 2 | Palm Bay Resort | Marco Deluca | Turin |
| 3 | Cedar Lodge | Jane Wu | NULL |
Entre para ver seu histórico de envios
EntrarEntre para usar o AI Mentor
Entrar