ソースコード
SELECT
    CASE WHEN ( SELECT COUNT(*) FROM CONVENIENCE WHERE SURVEY_YEAR = 2019 AND KIND_CODE = '100' ) % 2 = 0
            THEN (
                SELECT 
                    ROUND(AVG(X.TOTAL_VALUE)) AS SA_MEDIAN
                FROM (
                    SELECT TOTAL_VALUE
                        ,ROW_NUMBER() OVER(
                            ORDER BY TOTAL_VALUE DESC) AS NUM
                    FROM CONVENIENCE
                    WHERE SURVEY_YEAR = 2019 AND KIND_CODE = '100'
                    ) X
                WHERE X.NUM = ( SELECT COUNT(*) FROM CONVENIENCE WHERE SURVEY_YEAR = 2019 AND KIND_CODE = '100' ) / 2
                    OR X.NUM = ( SELECT COUNT(*) FROM CONVENIENCE WHERE SURVEY_YEAR = 2019 AND KIND_CODE = '100' ) / 2 + 1
                )
          WHEN ( SELECT COUNT(*) FROM CONVENIENCE WHERE SURVEY_YEAR = 2019 AND KIND_CODE = '100' ) % 2 = 1
            THEN (
                SELECT 
                    ROUND(AVG(Y.TOTAL_VALUE)) AS SA_MEDIAN
                FROM (
                    SELECT TOTAL_VALUE
                        ,ROW_NUMBER() OVER(
                            ORDER BY TOTAL_VALUE DESC) AS NUM
                    FROM CONVENIENCE
                    WHERE SURVEY_YEAR = 2019 AND KIND_CODE = '100'
                    ) Y
                WHERE Y.NUM = ( SELECT COUNT(*) FROM CONVENIENCE WHERE SURVEY_YEAR = 2019 AND KIND_CODE = '100' ) / 2 + 1
                )
          END
FROM CONVENIENCE
WHERE SURVEY_YEAR = 2019 AND KIND_CODE = '100'
提出情報
提出日時2022/12/12 00:23:31
コンテスト第4回 SQLコンテスト
問題中央値の算出
受験者S_Katou
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量94 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
94 MB
データパターン2
WA
94 MB
データパターン3
WA
92 MB