ソースコード
WITH DATA as (
        select 
            *
        from convenience
        where
           survey_year = 2019
        and kind_code = '100'
        ORDER BY total_value desc
        )

select
    case
        (
        select 
            count(*) as rowcnt
            from DATA
        ) % 2
    when 0 THEN
        (select 
            round(avg(total_value)) 
        from 
        (
            select 
                row_number() over win rownum,
                pf_code, total_value 
            from DATA
            WINDOW win AS (ORDER BY total_value desc)
        ) as tbl
        where 
            rownum IN
            (
            select 
                (count(*) / 2)
            from DATA
            UNION ALL
            select 
                (count(*) / 2) + 1
            from DATA
            )
        )
    when 1 THEN
        (select 
            round(avg(total_value)) 
        from 
        (
            select 
                row_number() over win rownum,
                pf_code, total_value 
            from DATA
            WINDOW win AS (ORDER BY total_value desc)
        ) as tbl
        where 
            rownum =
            (
            select 
                round(count(*) / 2)
            from DATA
            )
        )
    END as SA_MEDIAN
提出情報
提出日時2023/02/16 12:40:17
コンテスト第4回 SQLコンテスト
問題中央値の算出
受験者yakumo
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量76 MB
メッセージ
テストケース(通過数/総数)
2/3
状態
メモリ使用量
データパターン1
AC
76 MB
データパターン2
AC
76 MB
データパターン3
WA
76 MB