ソースコード
select
  RANK ( ) OVER ( order by POINT desc, EX_TIME )  as RANK
  ,USER_ID
  ,POINT
  ,EX_TIME
  ,WRONG_ANS
from (
select
  e.ENTRY_ID
  ,e.USER_ID
  ,strftime('%s', s1.SUBMITTED_AT ) - strftime('%s', e.STARTED_AT)
    + (ifnull(s3.counta,0) * 300) as EX_TIME
  ,s2.POINT
  ,ifnull(s3.counta,0) as WRONG_ANS
  
from ENTRIES e
left join (
  select
    max(SUBMITTED_AT) SUBMITTED_AT
    ,ENTRY_ID
  from SUBMISSIONS
  where
    STATUS = 'AC'
    and CONTEST_ID = 2
  group by
    ENTRY_ID
) s1
  on e.ENTRY_ID = s1.ENTRY_ID
left join (
  select
    sum(POINT) POINT
    ,ENTRY_ID
  from SUBMISSIONS
  where
    CONTEST_ID = 2
  group by
    ENTRY_ID
) s2
  on e.ENTRY_ID = s2.ENTRY_ID
  
left join (
  select
    count(*) counta
    ,s.ENTRY_ID
  from SUBMISSIONS s
  inner join (
    select
      SUBMITTED_AT
      ,ENTRY_ID
      ,PROBLEM_ID
      ,STATUS
    from SUBMISSIONS
    where
      CONTEST_ID = 2
      and STATUS = 'AC'
  ) ss
    on s.ENTRY_ID = ss.ENTRY_ID
    and s.PROBLEM_ID = ss.PROBLEM_ID
    and s.SUBMITTED_AT < ss.SUBMITTED_AT
  where
    s.STATUS <> 'AC'
  group by
    s.ENTRY_ID
) s3
  on e.ENTRY_ID = s3.ENTRY_ID
where
  s2.POINT > 0
  and e.CONTEST_ID = 2
)
order by 
  RANK
  ,WRONG_ANS
  ,USER_ID
提出情報
提出日時2022/10/20 01:35:40
コンテスト第3回 SQLコンテスト
問題順位計算
受験者tani.k1
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量104 MB
メッセージ
テストケース(通過数/総数)
2/2
状態
メモリ使用量
データパターン1
AC
80 MB
データパターン2
AC
104 MB