티스토리 뷰

https://leetcode.com/problems/confirmation-rate

 

Confirmation Rate - LeetCode

Can you solve this real interview question? Confirmation Rate - Table: Signups +----------------+----------+ | Column Name | Type | +----------------+----------+ | user_id | int | | time_stamp | datetime | +----------------+----------+ user_id is the prima

leetcode.com

with base as (
select
    user_id
    , count(distinct if(action = 'confirmed', time_stamp, null))/count(distinct time_stamp) confirmation_rate
from Confirmations
group by 1
)
select
    distinct c.user_id
    , if(b.confirmation_rate is null, 0, round(b.confirmation_rate,2)) confirmation_rate
from Signups c
left join base b on c.user_id = b.user_id

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

[SQL]weather-observation-station-5  (0) 2023.08.25
[SQL]rising-temperature  (0) 2023.08.24
[SQL]exchange-seats  (0) 2023.08.21
[SQL]friend-requests-ii-who-has-the-most-friends  (0) 2023.08.20
[SQL]game-play-analysis-iv  (0) 2023.08.19
공지사항
최근에 올라온 글
최근에 달린 댓글
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
글 보관함