ソースコード

SELECT
    RANK() OVER(ORDER BY C.POINT DESC, EX_TIME + 300 * COALESCE(WRONG_ANS, 0) ASC , WRONG_ANS ASC) AS RANK,
    MST.USER_ID,
    C.POINT,
    EX_TIME + COALESCE(WRONG_ANS, 0) * 300 AS EX_TIME,
    COALESCE(WRONG_ANS, 0) AS WRONG_ANS
FROM
    ENTRIES AS MST
INNER JOIN 
(
    SELECT
        E.ENTRY_ID,
        strftime('%s', ENDDT) - strftime('%s', STARTED_AT) AS EX_TIME
    FROM
        ENTRIES AS E
    INNER JOIN
    (
    SELECT
        ENTRY_ID,
        MAX(SUBMITTED_AT) AS ENDDT
    FROM
        SUBMISSIONS
    WHERE
        CONTEST_ID = 2 AND STATUS = 'AC'
    GROUP BY
        ENTRY_ID
    ) AS S ON E.ENTRY_ID = S.ENTRY_ID
) AS B ON MST.ENTRY_ID = B.ENTRY_ID
LEFT JOIN
(
    SELECT
        ENTRY_ID,
        SUM(POINT) AS POINT
    FROM
        SUBMISSIONS
    WHERE
        CONTEST_ID = 2 AND STATUS = 'AC'
    GROUP BY
        ENTRY_ID
) AS C ON B.ENTRY_ID = C.ENTRY_ID
LEFT JOIN
(
    SELECT
        ENTRY_ID,
        COUNT(1) AS WRONG_ANS
    FROM
        SUBMISSIONS
    WHERE
        CONTEST_ID = 2 AND STATUS = 'WA'
    GROUP BY
        ENTRY_ID
) AS D ON D.ENTRY_ID = C.ENTRY_ID
WHERE
    C.POINT > 0
ORDER BY
    RANK,
    EX_TIME,
    WRONG_ANS
提出情報
提出日時2022/10/19 23:18:58
コンテスト第3回 SQLコンテスト
問題順位計算
受験者telestate
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量81 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
81 MB
データパターン2
WA
79 MB