ソースコード
SELECT
    NO
    , TTL_SAL
    , ROUND(CAST(TTL_SAL AS REAL) * 100 / TOTAL_SAL, 1) AS PER_SAL
    , ROUND(CAST(SUM(TTL_SAL) OVER(ORDER BY NO) AS REAL) * 100 / TOTAL_SAL, 1) AS CUM_SAL
    , FLOOR(CAST(TTL_SAL AS REAL) / TTL_STR) AS AVG_SAL
FROM
    (
        SELECT
            GROUP_NO AS NO
            , SUM(SAL) AS TTL_SAL
            , SUM(STR) AS TTL_STR
            , TOTAL_SAL
        FROM
            (
                SELECT
                    PF_CODE
                    , SAL
                    , STR
                    , FLOOR(((ROW_NUMBER() OVER (ORDER BY SAL DESC, STR, PF_CODE)) - 1) / 3) + 1 AS GROUP_NO
                    , SUM(SAL) OVER() AS TOTAL_SAL
                FROM
                    (
                        SELECT
                            PF_CODE
                            , SUM(CASE WHEN KIND_CODE = 100 THEN TOTAL_VALUE ELSE 0 END) AS SAL
                            , SUM(CASE WHEN KIND_CODE = 150 THEN TOTAL_VALUE ELSE 0 END) AS STR
                        FROM 
                            CONVENIENCE
                        WHERE
                            SURVEY_YEAR = '2019'
                        GROUP BY
                            PF_CODE
                    )
            )
        GROUP BY
            GROUP_NO
    )
ORDER BY
    NO
;
提出情報
提出日時2023/11/11 16:45:05
コンテスト第9回 SQLコンテスト
問題販売額分析
受験者naku6aru
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量84 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
84 MB
データパターン3
AC
84 MB