MySQL Forums
Forum List  »  Optimizer & Parser

Re: Top 10 airports referenced from a table of flights
Posted by: Rick James
Date: June 15, 2009 10:23PM

Glad it helped.

This might fix my mistakes:
select x.apid, sum(x.ct) as ct
   from ( select src_apid as apid, count(*) as ct
             from flights
             GROUP BY src_apid
          UNION ALL
          select dst_apid as apid, count(*) as ct
             from flights
             GROUP BY dst_apid
        ) x
   group by apid
   order by ct desc
   limit 10;

Possible (if it works) it will run faster.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Top 10 airports referenced from a table of flights
2225
June 15, 2009 10:23PM


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.