ソースコード
WITH
CNT1 AS
(
SELECT
    COUNT(A.SURVEY_YEAR) AS CNT
FROM
    CONVENIENCE A
WHERE
    A.SURVEY_YEAR = 2019
AND A.KIND_CODE = '100'
),
CNT2 AS
(
SELECT
    CASE
        WHEN CNT % 2 = 0 THEN CNT / 2
        ELSE CNT / 2 + 0.5
    END AS CHK1
,   CASE
        WHEN CNT % 2 = 0 THEN CNT / 2 + 1
        ELSE 0
    END AS CHK2
,   CNT
FROM
    CNT1
),
WORK1 AS
(
SELECT
    A.*
,   RANK() OVER(ORDER BY A.TOTAL_VALUE DESC,A.PF_CODE) AS RNK
FROM
    CONVENIENCE A
WHERE
    A.SURVEY_YEAR = 2019
AND A.KIND_CODE = '100'
),
WORK2 AS
(
SELECT
    A.RNK
,   A.TOTAL_VALUE
FROM
    WORK1 A,
    CNT2
WHERE
    A.RNK = CHK1
UNION
SELECT
    A.RNK
,   A.TOTAL_VALUE
FROM
    WORK1 A,
    CNT2
WHERE
    A.RNK = CHK2
)
SELECT
    ROUND(AVG(A.TOTAL_VALUE)) AS SA_MEDIAN
FROM
    WORK2 A
提出情報
提出日時2023/02/05 22:42:36
コンテスト第4回 SQLコンテスト
問題中央値の算出
受験者TTSY_HR
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量79 MB
メッセージ
テストケース(通過数/総数)
2/3
状態
メモリ使用量
データパターン1
AC
79 MB
データパターン2
AC
76 MB
データパターン3
WA
79 MB