cjql / algorithm

https://cjql.github.io/algorithm/
1 stars 1 forks source link

sql: trips-and-users #16

Open cjql opened 4 years ago

cjql commented 4 years ago

https://leetcode.com/problems/trips-and-users/

SELECT Request_at as Day,
       ROUND(COUNT(IF(Status != 'completed', TRUE, NULL)) / COUNT(*), 2) AS 'Cancellation Rate'
FROM Trips
WHERE (Request_at BETWEEN '2013-10-01' AND '2013-10-03')
      AND Client_id NOT IN (SELECT Users_Id FROM Users WHERE Banned = 'Yes')
GROUP BY Request_at;

Runtime: 166 ms, faster than 99.72% of MySQL online submissions for Trips and Users. Memory Usage: 0B, less than 100.00% of MySQL online submissions for Trips and Users.