ETH官方钱包

前往
大廳
主題

MySQL練習 2020/2/29

艾倫D索妮雅 | 2021-06-10 19:54:31 | 巴幣 0 | 人氣 186

leetcode題:

我的code:
select whole.Day, convert(if(cls is null,0,cls/_all),decimal(15,2)) as `Cancellation Rate`
from (select count(NoBan.Status) as cls,NoBan.Request_at as Day
from( select *
from Trips,
(select Users_Id as cId,Banned as ban1 from Users where Role="client") as U1,
(select Users_Id as dId,Banned as ban2 from Users where Role="driver") as U2
where U1.cId = Trips.Client_Id and U1.ban1 <> "yes"
and U2.dId = Trips.Driver_Id and U2.ban2 <> "yes") as NoBan
where NoBan.Status = "cancelled_by_driver" or NoBan.Status = "cancelled_by_client"
group by NoBan.Request_at) as cls right join
(select count(NoBan.Status) as _all, NoBan.Request_at as Day
from( select *
from Trips,
(select Users_Id as cId,Banned as ban1 from Users where Role="client") as U1,
(select Users_Id as dId,Banned as ban2 from Users where Role="driver") as U2
where U1.cId = Trips.Client_Id and U1.ban1 <> "yes"
and U2.dId = Trips.Driver_Id and U2.ban2 <> "yes") as NoBan
group by NoBan.Request_at) as whole on whole.day = cls.day
where whole.Day = "2013-10-01" or whole.Day = "2013-10-02" or whole.Day = "2013-10-03"

創作回應

更多創作