ソースコード
with cnt as (
    select
        count(*) / 2 as cnt 
    from
        CONVENIENCE
    where
        SURVEY_YEAR = 2019
        AND KIND_CODE = '100'
),
top as (
    select
        *
    from (
        select
            TOTAL_VALUE
        from
            CONVENIENCE
        where
            SURVEY_YEAR = 2019
            AND KIND_CODE = '100'
        order by
            TOTAL_VALUE 
        limit (select cnt from cnt)
    )
    order by TOTAL_VALUE desc
    limit 1
),
bottom AS (
    select
        *
    from (
        select
            TOTAL_VALUE
        from
            CONVENIENCE
        where
            SURVEY_YEAR = 2019
            AND KIND_CODE = '100'
        order by
            TOTAL_VALUE DESC
        limit (select cnt from cnt)
    )
    order by TOTAL_VALUE
    limit 1
)
select
    round(avg(TOTAL_VALUE)) AS SA_MEDIAN
from (
    select TOTAL_VALUE from top
    union all
    select TOTAL_VALUE from bottom
)
;
提出情報
提出日時2022/12/12 07:01:14
コンテスト第4回 SQLコンテスト
問題中央値の算出
受験者SQL2022
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量77 MB
メッセージ
テストケース(通過数/総数)
2/3
状態
メモリ使用量
データパターン1
AC
76 MB
データパターン2
AC
76 MB
データパターン3
WA
77 MB