ソースコード


WITH data AS (
SELECT
TOTAL_VALUE AS SA_MEDIAN
FROM CONVENIENCE
WHERE SURVEY_YEAR = 2019
AND KIND_CODE = '100'
), x2 AS (
SELECT SA_MEDIAN
FROM data
ORDER BY SA_MEDIAN
LIMIT 2
OFFSET (SELECT CAST(COUNT(*) / 2 AS INTEGER) FROM data) - 1
), x AS (
SELECT SA_MEDIAN
FROM data
ORDER BY SA_MEDIAN
LIMIT 1
OFFSET (SELECT CAST(COUNT(*) / 2 AS INTEGER) FROM data) - 1
)

SELECT
CASE WHEN (SELECT MOD(COUNT(*), 2) FROM data) = 0
THEN
    (
    SELECT ROUND(AVG(SA_MEDIAN)) AS SA_MEDIAN
    FROM x2
    )
ELSE
    (
    SELECT ROUND(AVG(SA_MEDIAN)) AS SA_MEDIAN
    FROM x
    )
END AS SA_MEDIAN
提出情報
提出日時2022/12/12 01:29:18
コンテスト第4回 SQLコンテスト
問題中央値の算出
受験者mugenen
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量80 MB
メッセージ
テストケース(通過数/総数)
2/3
状態
メモリ使用量
データパターン1
AC
80 MB
データパターン2
AC
79 MB
データパターン3
WA
80 MB