ソースコード
WITH main AS 
(SELECT
 SUBMISSIONS.*,ENTRIES.STARTED_AT
FROM
 SUBMISSIONS
LEFT JOIN
 (SELECT USER_ID,STARTED_AT FROM ENTRIES WHERE CONTEST_ID = 2) AS ENTRIES
USING
 (USER_ID)
WHERE
 STATUS = 'AC'
AND
 CONTEST_ID = 2
AND
--エントリー外の集計を消す
 ENTRY_ID IS NOT NULL
),
--ユーザ-毎のご回答数をカウント
wrong_ans AS
(
SELECT
 USER_ID,
 COUNT(*) AS cnt
FROM
 SUBMISSIONS
WHERE
 STATUS = 'WA'
AND
 CONTEST_ID = 2
AND
--エントリー外の集計を消す
 ENTRY_ID IS NOT NULL
GROUP BY
 USER_ID
)
SELECT
 RANK()OVER(ORDER BY SUM(POINT) DESC,IFNULL(MAX(cnt),0) ASC) AS RANK,
 USER_ID,
 SUM(POINT) AS POINT,
 strftime('%s',MAX(SUBMITTED_AT)) - strftime('%s',MIN(STARTED_AT)) + (IFNULL(MAX(cnt),0) * 300) AS EX_TIME,
 IFNULL(MAX(cnt),0) AS WRONG_ANS
FROM
 main
LEFT JOIN
 wrong_ans
USING
 (USER_ID)
GROUP BY
 USER_ID
HAVING
 SUM(POINT) <> 0
ORDER BY
 RANK,WRONG_ANS,USER_ID
提出情報
提出日時2024/02/04 21:13:58
コンテスト第3回 SQLコンテスト
問題順位計算
受験者romi0416
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量85 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
84 MB
データパターン2
WA
85 MB