티스토리 뷰

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

select 
    t.request_at as Day
    , round(1.00*count(distinct(if(t.status like 'cancel%', t.id, null)))/count(distinct t.id), 2) as 'Cancellation Rate'
from trips t
left join users u on t.client_id = u.users_id
    and u.role = 'client' and u.banned = 'No'
left join users u2 on t.driver_id = u2.users_id 
    and u2.role = 'driver' and u2.banned = 'No'
where u.users_id is not null and u2.users_id is not null
    and t.request_at between date('2013-10-01') and date('2013-10-03')
group by 1

 

 

'프로그래밍연습 > SQL' 카테고리의 다른 글

[SQL]game-play-analysis-iv  (0) 2023.08.19
[SQL]human-traffic-of-stadium  (0) 2023.08.18
[SQL]employees-earning-more-than-their-managers  (0) 2023.08.17
[SQL]consecutive-numbers  (0) 2023.08.17
[SQL]SecondHighestSalary_leatcode  (0) 2023.08.17
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함