inblog logo
|
silver
    SQL문제풀기

    [SQL문제풀기] Meta/Facebook Accounts

    silver's avatar
    silver
    Jan 19, 2026
    [SQL문제풀기] Meta/Facebook Accounts
    Contents
    문제내가 작성한 오답내가 작성한 정답

    문제

    StrataScratch - Meta/Facebook Accounts
    StrataScratch
    StrataScratch - Meta/Facebook Accounts
    https://platform.stratascratch.com/coding/10296-facebook-accounts?code_type=3

    내가 작성한 오답

    : 2020-01-10일전부터 2020-01-10까지의 id들을 다 포함시켰다
    select count(case when status = 'closed' then 1 end )*1.00/ count(acc_id) closed_ratio from fb_account_status where (acc_id,status_date) in (select acc_id, max(status_date) from fb_account_status where date(status_date) <= '2020-01-10' group by acc_id);

    내가 작성한 정답

    : 2020-01-10일 당일의 기록만 구하면 된다

    MySQL, PostgreSQL

    select count(case when status = 'closed' then 1 end )*1.00/ count(acc_id) closed_ratio from fb_account_status where date(status_date) = '2020-01-10';

    Oracle

    select count(case when status = 'closed' then 1 end )*1.00/ count(acc_id) closed_ratio from fb_account_status where to_char(status_date,'yyyy-mm-dd') = '2020-01-10';
    Share article

    silver

    RSS·Powered by Inblog