SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
SELECT LPAD(FLOOR(AVG(EXTRACT(EPOCH FROM actual_departure - scheduled_departure))::INTEGER / 3600)::TEXT, 2, '0') || ':' || LPAD(FLOOR(MOD(AVG(EXTRACT(EPOCH FROM actual_departure - scheduled_departure))::INTEGER / 60, 60))::TEXT, 2, '0') || ':' || LPAD(FLOOR(MOD(AVG(EXTRACT(EPOCH FROM actual_departure - scheduled_departure))::INTEGER, 60))::TEXT, 2, '0') AS average_departure_delay, LPAD(FLOOR(MAX(EXTRACT(EPOCH FROM actual_departure - scheduled_departure))::INTEGER / 3600)::TEXT, 2, '0') || ':' || LPAD(FLOOR(MOD(MAX(EXTRACT(EPOCH FROM actual_departure - scheduled_departure))::INTEGER / 60, 60))::TEXT, 2, '0') || ':' || LPAD(MOD(MAX(EXTRACT(EPOCH FROM actual_departure - scheduled_departure))::INTEGER, 60)::TEXT, 2, '0') AS maximal_departure_delay FROM flights WHERE departure_airport = 'DME' AND EXTRACT(YEAR FROM scheduled_departure) = 2017 AND EXTRACT(MONTH FROM scheduled_departure) = 8; ; select * from query_cost('SELECT LPAD(FLOOR(AVG(EXTRACT(EPOCH FROM actual_departure - scheduled_departure))::INTEGER / 3600)::TEXT, 2, ''0'') || '':'' || LPAD(FLOOR(MOD(AVG(EXTRACT(EPOCH FROM actual_departure - scheduled_departure))::INTEGER / 60, 60))::TEXT, 2, ''0'') || '':'' || LPAD(FLOOR(MOD(AVG(EXTRACT(EPOCH FROM actual_departure - scheduled_departure))::INTEGER, 60))::TEXT, 2, ''0'') AS average_departure_delay, LPAD(FLOOR(MAX(EXTRACT(EPOCH FROM actual_departure - scheduled_departure))::INTEGER / 3600)::TEXT, 2, ''0'') || '':'' || LPAD(FLOOR(MOD(MAX(EXTRACT(EPOCH FROM actual_departure - scheduled_departure))::INTEGER / 60, 60))::TEXT, 2, ''0'') || '':'' || LPAD(MOD(MAX(EXTRACT(EPOCH FROM actual_departure - scheduled_departure))::INTEGER, 60)::TEXT, 2, ''0'') AS maximal_departure_delay FROM flights WHERE departure_airport = ''DME'' AND EXTRACT(YEAR FROM scheduled_departure) = 2017 AND EXTRACT(MONTH FROM scheduled_departure) = 8; ');

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear