문제 : https://leetcode.com/problems/trips-and-users/
Trips and Users - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
banned된 고객이 신청한게 아닌 예약들 중에 취소된 비율을 구하는 문제입니다.
오라클 Oracle 풀이
SELECT
request_at as Day
,round(COUNT(case status when 'cancelled_by_driver' then 1
when 'cancelled_by_client' then 1 else null end)/ count(1), 2) as "Cancellation Rate"
from Trips T
where t.request_at between '2013-10-01' and '2013-10-03'
and exists (select 1
from Users U
where T.client_id = U.users_id
and U.banned = 'No')
and exists (select 1
from Users U
where T.driver_id = U.users_id
and U.banned = 'No')
group by request_at
'알고리즘 > 코딩테스트' 카테고리의 다른 글
[SQL] leetCode Department Top Three Salaries (0) | 2022.03.24 |
---|---|
[SQL] leetcode Second Highest Salary (0) | 2022.03.22 |
리트코드 leetCode 743.Network Delay Time (0) | 2021.11.05 |
프로그래머스 가장 먼 노드 (0) | 2021.11.03 |
리트코드 leetCode binary-tree-right-side-view (0) | 2021.10.28 |