SQL code copied to buffer
Sharpen your SQL skills with our interactive exercises and assessments!
Practice a wide range of SQL tasks, from basic queries to advanced techniques. Get immediate feedback on your solutions, helping you learn from mistakes and improve your skills. Boost your confidence for job interviews and real-world SQL applications.
RU PT
Explore over 300 diverse tasks on our platform.
Task 167:
Find the length of the hypotenuse of a right triangle with legs equal to 2 and 3.
Output the result in the hypotenuse column. Round the result to three decimal places.

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.
Get hint
Copy code Clear editor

Bookings Database (PostgreSQL)

The subject area of this database is airline flights through various airports.

ER diagram of the Bookings database

The Bookings Database contains 8 tables:

aircrafts_data - table of aircrafts.
  • aircraft_codeUnique code for each aircraft.
  • modelAircraft model name in English and Russian in JSON format.
  • rangeAircraft fly range in kilometers.
  • PRIMARY KEY, btree (aircraft_code)
aircraft_codemodelrange
1773{"en": "Boeing 777-300", "ru": "Боинг 777-300"}11100
airports_data - table of airports.
  • airport_codeUnique code for each airport.
  • airport_nameAirport name in English and Russian in JSON format.
  • cityAirport city in English and Russian in JSON format.
  • coordinatesAirport coordinates as POINT(longitude, latitude).
  • timezoneAirport timezone name.
  • PRIMARY KEY, btree (airport_code)
airport_codeairport_namecitycoordinatestimezone
1YKS{"en": "Yakutsk Airport", "ru": "Якутск"}{"en": "Yakutsk", "ru": "Якутск"}(129.77099609375,62.0932998657227)Asia/Yakutsk
boarding_passes - table of boarding passes.
  • ticket_noTicket number.
  • flight_idFlight identificator.
  • boarding_noBoarding pass number.
  • seat_noSeat number.
  • PRIMARY KEY, btree (ticket_no, flight_id)
  • UNIQUE CONSTRAINT, btree (flight_id, boarding_no)
  • UNIQUE CONSTRAINT, btree (flight_id, seat_no)
  • FOREIGN KEY (ticket_no, flight_id) REFERENCES ticket_flights(ticket_no, flight_id)
ticket_noflight_idboarding_noseat_no
100054352123513062512D
bookings - table of bookings.
  • book_refBooking number.
  • book_dateBooking date.
  • total_amountTotal booking cost.
  • PRIMARY KEY, btree (book_ref)
book_refbook_datetotal_amount
100000F2017-07-05 00:12:00+00265700.00
flights - table of flights.
  • flight_idFlight ID.
  • flight_noFlight number.
  • scheduled_departureScheduled departure time.
  • scheduled_arrivalScheduled arrival time.
  • departure_airportAirport of departure.
  • arrival_airportAirport of arrival.
  • statusFlight status.
  • aircraft_codeAircraft code, IATA.
  • actual_departureActual departure time.
  • actual_arrivalActual arrival time.
  • PRIMARY KEY, btree (flight_id)
  • UNIQUE CONSTRAINT, btree (flight_no, scheduled_departure)
flight_id flight_no scheduled_departure scheduled_arrival departure_airport arrival_airport status aircraft_code actual_departure actual_arrival
11185PG01342017-09-10 06:50:00+002017-09-10 11:55:00+00DMEBTKScheduled319
seats - table of aircraft seats.
  • aircraft_codeAircraft code, IATA.
  • seat_noSeat number.
  • fare_conditionsTravel class.
  • PRIMARY KEY, btree (aircraft_code, seat_no)
  • FOREIGN KEY (aircraft_code) REFERENCES aircrafts(aircraft_code) ON DELETE CASCADE
aircraft_codeseat_nofare_conditions
13192ABusiness
ticket_flights - ticket to flights relations.
  • ticket_noTicket number.
  • flight_idFlight ID.
  • fare_conditionsTravel class.
  • amountTravel cost.
  • PRIMARY KEY, btree (ticket_no, flight_id)
  • FOREIGN KEY (flight_id) REFERENCES flights(flight_id)
  • FOREIGN KEY (ticket_no) REFERENCES tickets(ticket_no)
ticket_no flight_id fare_conditions amount
1000543215977630625Business42100.00
tickets - table of tickets.
  • ticket_noTicket number.
  • book_refBooking number.
  • passenger_idPassenger ID.
  • passenger_namePassenger name.
  • contact_dataPassenger contact information.
ticket_no book_ref passenger_id passenger_name contact_data
1000543200098706B0468149 604011VALERIY TIKHONOV{"phone": "+70127117011"}
  • PRIMARY KEY, btree (ticket_no)
  • FOREIGN KEY (book_ref) REFERENCES bookings(book_ref)