ソースコード
WITH STEP_1 AS 
(
  SELECT 
   AVG(POINT) AS AVG_POINT
  FROM TEST_RESULTS
  WHERE TEST_ID = '100'
)
, STEP_2 AS 
(
  SELECT 
    USER_ID 
    ,POINT 
    ,POINT - STEP_1.AVG_POINT AS DIFF 
  FROM TEST_RESULTS
  CROSS JOIN STEP_1
  WHERE TEST_ID = '100'
)
, STEP_3 AS 
(
  SELECT 
    AVG(DIFF*DIFF) AS SQUAVG
  FROM STEP_2 
)
,STEP_4 AS 
(
  SELECT 
    SQRT(SQUAVG) AS SD 
  FROM STEP_3 
)
,STEP_5 AS 
(
  SELECT 
    USER_ID 
    ,POINT
    ,DIFF*10 AS DIFF10
  FROM STEP_2 
)
  SELECT 
    USER_ID AS USER 
    ,POINT AS PT 
    ,case when sd = 0 then 50
      else ROUND(50 + DIFF10 / SD, 1) 
      end AS DEV_VAL
  FROM STEP_5 
  CROSS JOIN STEP_4 
ORDER BY DEV_VAL DESC, USER
;
提出情報
提出日時2023/02/20 09:39:42
コンテスト第5回 SQLコンテスト
問題偏差値の算出
受験者hattsuriboy
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量81 MB
メッセージ
テストケース(通過数/総数)
4/4
状態
メモリ使用量
データパターン1
AC
81 MB
データパターン2
AC
79 MB
データパターン3
AC
76 MB
データパターン4
AC
79 MB