🙏 We need your help! SQLtest.online has no ads and lives only on donations. Even a small amount helps. Donate now →
SQL code copied to buffer
Task 18:

Rebook a Return Flight in One Transaction

PostgreSQL
The family of booking 070133 moves its return trip from flight 29184 (August 19) to flight 29194 (August 20). Two changes are needed, and they must be saved together or not at all:
1. in ticket_flights, replace flight_id 29184 with 29194 for all tickets of the booking (the tickets are in the tickets table);
2. in bookings, add the change fee of 5000 to total_amount.
Make both changes in one transaction.
Expected result Columns: 3 · Rows: 10
ticket_no flight_id total_amount

Sample rows open after wrong checks: 0 of 2

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

Tutorial

By checking a query, you agree that it is stored without your account details and may be included in anonymized datasets, including for AI training. Learn more

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