Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
/*select case when to_char(scheduled_departure, 'YYYY-MM')='2017-08' then to_char(scheduled_departure, 'YYYY-MM-DD') else NULL end, case when to_char(scheduled_arrival, 'YYYY-MM')='2017-08' then to_char(scheduled_arrival, 'YYYY-MM-DD') else NULL end, from flights where (departure_airport='VOZ' or arrival_airport='VOZ') and (to_char(scheduled_departure, 'YYYY-MM')='2017-08' or to_char(scheduled_arrival, 'YYYY-MM')='2017-08') */ with q1 as (select to_char(scheduled_departure, 'YYYY-MM-DD') date, 1 detartures_count, 0 arrivals_count from flights where departure_airport='VOZ' and to_char(scheduled_departure, 'YYYY-MM')='2017-08' UNION ALL select to_char(scheduled_arrival, 'YYYY-MM-DD') date, 0, 1 arrivals_count from flights where arrival_airport='VOZ' and to_char(scheduled_arrival, 'YYYY-MM')='2017-08') select date, SUM(detartures_count) detartures_count, SUM(arrivals_count) arrivals_count from q1 group by date order by 1 ; select * from query_cost('/*select case when to_char(scheduled_departure, ''YYYY-MM'')=''2017-08'' then to_char(scheduled_departure, ''YYYY-MM-DD'') else NULL end, case when to_char(scheduled_arrival, ''YYYY-MM'')=''2017-08'' then to_char(scheduled_arrival, ''YYYY-MM-DD'') else NULL end, from flights where (departure_airport=''VOZ'' or arrival_airport=''VOZ'') and (to_char(scheduled_departure, ''YYYY-MM'')=''2017-08'' or to_char(scheduled_arrival, ''YYYY-MM'')=''2017-08'') */ with q1 as (select to_char(scheduled_departure, ''YYYY-MM-DD'') date, 1 detartures_count, 0 arrivals_count from flights where departure_airport=''VOZ'' and to_char(scheduled_departure, ''YYYY-MM'')=''2017-08'' UNION ALL select to_char(scheduled_arrival, ''YYYY-MM-DD'') date, 0, 1 arrivals_count from flights where arrival_airport=''VOZ'' and to_char(scheduled_arrival, ''YYYY-MM'')=''2017-08'') select date, SUM(detartures_count) detartures_count, SUM(arrivals_count) arrivals_count from q1 group by date order by 1');

Stuck with a problem? Got Error? Ask AI support!

Copy Clear