ソースコード
SELECT
    RANK() OVER (ORDER BY POINT DESC, TIME + WRONG_ANS * 300 ASC) AS RANK,
    USER_ID,
    POINT,
    TIME + WRONG_ANS * 300 AS EX_TIME,
    WRONG_ANS
FROM (
    SELECT
        ENTRIES.USER_ID,
        SUM(SUBMISSIONS.POINT) AS POINT,
        CAST(STRFTIME('%s', MAX(SUBMISSIONS.SUBMITTED_AT)) AS INT) - CAST(STRFTIME('%s', ENTRIES.STARTED_AT) AS INT) AS TIME,
        SUM(CASE SUBMISSIONS.STATUS WHEN 'AC' THEN 0 ELSE 1 END) AS WRONG_ANS
    FROM
        SUBMISSIONS
    INNER JOIN
        ENTRIES ON
        ENTRIES.CONTEST_ID = SUBMISSIONS.CONTEST_ID AND
        ENTRIES.ENTRY_ID = SUBMISSIONS.ENTRY_ID
    INNER JOIN (
        SELECT
            CONTEST_ID,
            PROBLEM_ID,
            ENTRY_ID,
            SUBMITTED_AT,
            POINT
        FROM
            SUBMISSIONS
        WHERE
            CONTEST_ID = 2 AND
            ENTRY_ID IS NOT NULL AND
            STATUS = 'AC'
    ) AS
        LAST_SUBMISSIONS ON
        LAST_SUBMISSIONS.CONTEST_ID = SUBMISSIONS.CONTEST_ID AND
        LAST_SUBMISSIONS.PROBLEM_ID = SUBMISSIONS.PROBLEM_ID AND
        LAST_SUBMISSIONS.ENTRY_ID = SUBMISSIONS.ENTRY_ID AND
        LAST_SUBMISSIONS.SUBMITTED_AT >= SUBMISSIONS.SUBMITTED_AT
    GROUP BY
        ENTRIES.USER_ID,
        ENTRIES.STARTED_AT
) AS SUBMISSIONS
ORDER BY
    RANK ASC,
    WRONG_ANS ASC,
    USER_ID ASC
提出情報
提出日時2022/10/20 01:37:18
コンテスト第3回 SQLコンテスト
問題順位計算
受験者naoigcat
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量104 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
81 MB
データパターン2
AC
104 MB