ソースコード
SELECT
    RANK() OVER(ORDER BY 
            POINT DESC,
            (strftime('%s', M_AT) - strftime('%s', S_AT) + (WA * 300)) ASC
        ) AS RANK
    ,USER_ID
    ,POINT
    ,(strftime('%s', M_AT) - strftime('%s', S_AT) + (WA * 300)) AS EX_TIME
    ,WA AS WRONG_ANS
FROM
    (
        SELECT
             E.USER_ID
            ,E.STARTED_AT AS S_AT
            ,SUM(S.POINT) AS POINT
            ,COUNT(CASE WHEN S.STATUS <> 'AC' AND S.SUBMITTED_AT < AC.SUBMITTED_AT THEN 1 ELSE NULL END ) AS WA
            ,MAX(AC.SUBMITTED_AT) AS M_AT
        FROM
            ENTRIES AS E
            LEFT JOIN
                SUBMISSIONS AS S
            ON
                E.ENTRY_ID = S.ENTRY_ID
            AND E.CONTEST_ID = S.CONTEST_ID
            LEFT JOIN
                (
                    SELECT
                         PROBLEM_ID
                        ,ENTRY_ID
                        ,MAX(SUBMITTED_AT) AS SUBMITTED_AT
                    FROM
                        SUBMISSIONS
                    WHERE
                            CONTEST_ID ='2'
                        AND STATUS = 'AC'
                    GROUP BY
                         PROBLEM_ID
                        ,ENTRY_ID
                ) AS AC
            ON
                    S.PROBLEM_ID = AC.PROBLEM_ID
                AND S.ENTRY_ID = AC.ENTRY_ID
        WHERE
                E.CONTEST_ID ='2'
            AND S.ENTRY_ID IS NOT NULL
            --AND S.SUBMITTED_AT BETWEEN E.STARTED_AT AND datetime(E.STARTED_AT, '+1 hours')
        GROUP BY
            E.USER_ID
            ,E.STARTED_AT
    ) AS TBL
WHERE
    POINT > 0
ORDER BY
    RANK
    ,WA
    ,USER_ID
提出情報
提出日時2022/10/20 13:13:36
コンテスト第3回 SQLコンテスト
問題順位計算
受験者SI_KK
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量81 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
80 MB
データパターン2
AC
81 MB