ソースコード
WITH RANK_AMOUNT AS
(
    SELECT
        RANK() OVER(ORDER BY TOTAL_VALUE DESC) AS RANK,
        TOTAL_VALUE
    FROM
        CONVENIENCE
    WHERE
        SURVEY_YEAR = 2019
    AND KIND_CODE = '100'
),
RANK_POINT AS
(
    SELECT
        CASE WHEN MOD(MAX(RANK), 2) = 0 THEN ROUND(MAX(RANK) / CAST(2 AS DOUBLE), 0)
             ELSE ROUND(MAX(RANK) / CAST(2 AS DOUBLE), 0)
        END AS SU_1,
        CASE WHEN MOD(MAX(RANK), 2) = 0 THEN ROUND(MAX(RANK) / CAST(2 AS DOUBLE), 0) + 1
             ELSE ROUND(MAX(RANK) / CAST(2 AS DOUBLE), 0)
        END AS SU_2
    FROM
        RANK_AMOUNT
)
SELECT
    ROUND(CAST((RANK_1.TOTAL_VALUE + RANK_2.TOTAL_VALUE) AS DOUBLE) / CAST(2 AS DOUBLE), 0) AS SA_MEDIAN
FROM
    RANK_POINT
    INNER JOIN
    RANK_AMOUNT AS RANK_1
    ON RANK_POINT.SU_1 = RANK_1.RANK
    INNER JOIN
    RANK_AMOUNT AS RANK_2
    ON RANK_POINT.SU_2 = RANK_2.RANK
;
提出情報
提出日時2022/12/09 18:39:26
コンテスト第4回 SQLコンテスト
問題中央値の算出
受験者hiro200261
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量94 MB
メッセージ
テストケース(通過数/総数)
2/3
状態
メモリ使用量
データパターン1
AC
94 MB
データパターン2
AC
78 MB
データパターン3
WA
83 MB