【Leetcode-Mysql】Trips and Users
思路不总结了,看过题目自己尝试过之后,看下方代码应该能理解的
SELECT Request_at AS DAY, round( sum( CASE WHEN STATUS = 'completed' THEN 0 ELSE 1 END ) / count(Id), 2 ) AS 'Cancellation Rate' FROM Trips WHERE Client_Id IN ( SELECT Users_Id FROM Users WHERE Banned = 'NO' AND Role = 'client' ) AND Request_at >= '2013-10-01' AND Request_at <= '2013-10-03' GROUP BY Request_at;