ソースコード

SELECT
    TILE_NO AS 'NO',
    TTL_SAL,
    PER_SAL,
    ROUND(
        SUM(PER_SAL) OVER (
            ORDER BY
                PER_SAL DESC ROWS UNBOUNDED PRECEDING
        ),
        1
    ) AS CUM_SAL,
    AVG_SAL
FROM
    (
        SELECT
            TILE_NO,
            SUM (SALES_VALUE) AS TTL_SAL,
            ROUND (
                SUM(SALES_VALUE) * 100.0 / (
                    SELECT
                        SUM(SALES_VALUE)
                    FROM
                        (
                            SELECT
                                PF_CODE,
                                TOTAL_VALUE AS SALES_VALUE
                            FROM
                                CONVENIENCE
                            WHERE
                                SURVEY_YEAR = 2019
                                AND KIND_CODE = '100'
                        )
                ),
                1
            ) AS PER_SAL,
            SUM(SALES_VALUE) / SUM(STORE_COUNT) AS AVG_SAL
        FROM
            (
                SELECT
                    PF_CODE,
                    SALES_VALUE,
                    STORE_COUNT,
                    NTILE (10) OVER (
                        ORDER BY
                            SALES_VALUE DESC,
                            STORE_COUNT ASC,
                            PF_CODE ASC
                    ) AS TILE_NO
                FROM
                    (
                        SELECT
                            PF_CODE,
                            SALES_VALUE,
                            STORE_COUNT
                        FROM
                            (
                                SELECT
                                    PF_CODE,
                                    TOTAL_VALUE AS SALES_VALUE
                                FROM
                                    CONVENIENCE
                                WHERE
                                    SURVEY_YEAR = 2019
                                    AND KIND_CODE = '100'
                            ) AS A
                            INNER JOIN (
                                SELECT
                                    PF_CODE,
                                    TOTAL_VALUE AS STORE_COUNT
                                FROM
                                    CONVENIENCE
                                WHERE
                                    SURVEY_YEAR = 2019
                                    AND KIND_CODE = '150'
                            ) AS B USING (PF_CODE)
                    )
            )
        GROUP BY
            TILE_NO
    )
ORDER BY
    TILE_NO ASC;
提出情報
提出日時2023/10/14 18:14:29
コンテスト第9回 SQLコンテスト
問題販売額分析
受験者HyperToy
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量77 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
77 MB
データパターン2
WA
76 MB
データパターン3
WA
77 MB