ソースコード

with sumpoint as (
  select
    s.USER_ID,
    sum(s.POINT) po
  from 
    SUBMISSIONS s
  where 
    s.CONTEST_ID = 2
  group by 
    s.USER_ID
)
, zikan1 as (
  select 
    e.USER_ID
    ,ss.at
    ,e.STARTED_AT
  from 
    (
    select
      s.USER_ID,
      sum(ifnull(SUBMITTED_AT,0)) at
    from 
      SUBMISSIONS s
    where 
      s.CONTEST_ID = 2
      and STATUS = 'AC'
    group by 
      s.USER_ID
    ) ss
    ,ENTRIES e
  where 
    ss.USER_ID = e.USER_ID
    and e.CONTEST_ID = 2
)
, gotou as (
  select 
    s1.USER_ID
    ,count(SUBMITTED_AT) as gtcnt
  from 
    SUBMISSIONS s1
    inner join 
      zikan1
        on s1.USER_ID = zikan1.USER_ID
        and s1.CONTEST_ID = 2
  where 
    zikan1.at > s1.SUBMITTED_AT
    and s1.STATUS <> 'AC'
  group by 
    s1.USER_ID
)
select
    RANK() OVER(
      ORDER BY
         sumpoint.po DESC,
         (zikan1.at - zikan1.STARTED_AT) + (ifnull(gotou.gtcnt,0)*300)
      ) as RANK
   ,sumpoint.USER_ID as USER_ID
   ,sumpoint.po as POINT
   ,(zikan1.at - zikan1.STARTED_AT) + (ifnull(gotou.gtcnt,0)*300) as EX_TIME
   ,ifnull(gotou.gtcnt,0) as WRONG_ANS
from
  sumpoint
  left join zikan1 on sumpoint.USER_ID = zikan1.USER_ID
  left join gotou on sumpoint.USER_ID = gotou.USER_ID

order by 
 RANK desc
 ,WRONG_ANS asc
 ,USER_ID
提出情報
提出日時2022/10/19 22:11:05
コンテスト第3回 SQLコンテスト
問題順位計算
受験者idakazoo
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量107 MB
メッセージ
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
WA
107 MB
データパターン2
WA
104 MB