SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
select DENSE_RANK() over (ORDER BY round( (count(case when actual_departure - scheduled_departure > '00:30:00' THEN 1 END)::numeric / count(*)) * 100, 2))airport_rank, airport_name ->> 'en' airport_name, --count(*) total_flights, --count(case when actual_departure - scheduled_departure > '00:30:00' THEN 1 END) delayed_flights, round( (count(case when actual_departure - scheduled_departure > '00:30:00' THEN 1 END)::numeric / count(*)) * 100, 2) delayed_flights_rate from flights f left join airports_data a on f.departure_airport = a.airport_code group by airport_name ->> 'en', date_trunc('month',actual_departure) having count (*) > 100

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear