SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
WITH flight_data AS ( SELECT flight_id, departure_lat, departure_lon, arrival_lat, arrival_lon, flight_duration, TIMESTAMPDIFF(MINUTE, departure_time, NOW()) AS elapsed_time FROM flights WHERE flight_id = 475 ), intermediate_position AS ( SELECT flight_id, departure_lat + (arrival_lat - departure_lat) * LEAST(30, elapsed_time) / flight_duration AS current_lat, departure_lon + (arrival_lon - departure_lon) * LEAST(30, elapsed_time) / flight_duration AS current_lon FROM flight_data ) SELECT JSON_ARRAY(current_lat, current_lon) AS current_coordinates FROM intermediate_position; ; select * from query_cost('WITH flight_data AS ( SELECT flight_id, departure_lat, departure_lon, arrival_lat, arrival_lon, flight_duration, TIMESTAMPDIFF(MINUTE, departure_time, NOW()) AS elapsed_time FROM flights WHERE flight_id = 475 ), intermediate_position AS ( SELECT flight_id, departure_lat + (arrival_lat - departure_lat) * LEAST(30, elapsed_time) / flight_duration AS current_lat, departure_lon + (arrival_lon - departure_lon) * LEAST(30, elapsed_time) / flight_duration AS current_lon FROM flight_data ) SELECT JSON_ARRAY(current_lat, current_lon) AS current_coordinates FROM intermediate_position; ');

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear