MySQL Forums
Forum List  »  Newbie

Re: Order By in FROM Subquery doesn't work in 5.7
Posted by: zhiren Yip
Date: April 16, 2016 12:21AM

    SELECT  t2.*,t1.AbnormalCount,count(*) as TotalCount,(1- t1.AbnormalCount/count(*)) as NormalRate
        FROM  
          ( SELECT  *
                FROM  `FlightOnTime`.`FlightOnTime`
                WHERE  (`FlightDate` BETWEEN '2016-04-01' AND '2016-04-14')
                  AND  `DepAP` IN (SOMETHING)AND `Reg` IN (SOMETHING)
                ORDER BY  `FlightDate` DESC
          )t2,
          ( SELECT  FlightNo,DepAP,ArrAP,count(*) as AbnormalCount
                FROM  `FlightOnTime`.`FlightOnTime`
                WHERE  (`FlightDate` BETWEEN '2016-04-01' AND '2016-04-14')
                  AND  `normalFlag` = -1
                  AND  `DepAP` IN (SOMETHING)AND `Reg` IN (SOMETHING))t1
                WHERE  t2.`FlightNo` = t1.`FlightNo`
                  AND  t2.`DepAP`=t1.`DepAP`
                  AND  t2.`ArrAP`=t1.`ArrAP`
                GROUP BY  t2.`FlightNo`,t2.`DepAP`
                ORDER BY  `NormalRate`,t2.`FlightNo`

sorry for the format of the sql . because this sql is not type by myself but build in my program and miss a ")" after copy.

SOMETHING is a array of string , i replae with SOMETHING for readable .

I test last night with a mysql 5.6.28 installed from mysql installer.
it work fine .

SO , the question now is the verision between 5.6 and 5.7 .

Options: ReplyQuote


Subject
Written By
Posted
Re: Order By in FROM Subquery doesn't work in 5.7
April 16, 2016 12:21AM


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.