728x90
# Write your MySQL query statement below
select
Trips.Request_at as Day,
round(sum(if(status != 'completed',1,0)) / count(*), 2) as 'Cancellation Rate'
from
Trips, Users
where
Trips.Client_Id = Users.Users_Id and
Users.Banned = "No" and
Trips.Request_at BETWEEN '2013-10-01' and '2013-10-03'
group by
Trips.Request_at
출처: tanwirkhan.medium.com/leet-code-262-trips-and-users-5899bf04ec0e
728x90
'SQL' 카테고리의 다른 글
[LeetCode] Department Top Three Salaries (partition by, rank, sub query) (0) | 2021.04.10 |
---|---|
[LeetCode] Department Highest Salary ( sub query, partition by) (0) | 2021.04.10 |
SQL 실행 순서와 문법 순서 (0) | 2021.04.10 |
[LeetCode] Consecutive Numbers (self join twice) (0) | 2021.04.10 |
[LeetCode] Rank Scores (rank, dense rank, row number) (0) | 2021.04.10 |
댓글