Re: Top 10 airports referenced from a table of flights
OR is not well optimized; UNION works better.
See if either of these works adequately:
select apid, count(*) as ct
from (
select src_apid as apid
from flights
UNION
select dst_apid as apid
from flights
) x
group by apid
order by count(*) desc
limit 10;
select x.apid, sum(x.ct) as ct
from ( select src_apid as apid, count(*) as ct
from flights
UNION
select src_apid as apid, count(*) as ct
from flights ) x
group by apid
order by ct desc
limit 10;
/code]
Subject
Views
Written By
Posted
5130
June 09, 2009 12:40AM
Re: Top 10 airports referenced from a table of flights
2199
June 11, 2009 10:46PM
2254
June 11, 2009 10:48PM
2366
June 15, 2009 10:16AM
2226
June 15, 2009 10:23PM
3288
June 16, 2009 03:35AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.