ソースコード
WITH AVG as (
 SELECT AVG(POINT) AS avg FROM TEST_RESULTS WHERE TEST_ID = '100'
), DIFF as (
 SELECT point - avg AS diff FROM TEST_RESULTS LEFT OUTER JOIN AVG WHERE TEST_ID = '100'
), VARIANCE as (
 SELECT AVG(POW(diff, 2)) as variance FROM DIFF
), SIGMA as(
 SELECT SQRT(variance) AS sigma FROM VARIANCE
)
 
SELECT
result.USER_ID AS USER,
result.POINT AS PT,
CASE
 WHEN SIGMA = 0 THEN 50
 ELSE ROUND((result.point - avg) * 10 / sigma + 50, 1) 
END AS DEV_VAL
FROM TEST_RESULTS result
LEFT OUTER JOIN AVG
LEFT OUTER JOIN SIGMA
WHERE TEST_ID = '100'
ORDER BY DEV_VAL DESC, result.USER_ID ASC;
提出情報
提出日時2023/02/18 15:07:28
コンテスト第5回 SQLコンテスト
問題偏差値の算出
受験者daisuzz
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量78 MB
メッセージ
テストケース(通過数/総数)
4/4
状態
メモリ使用量
データパターン1
AC
77 MB
データパターン2
AC
78 MB
データパターン3
AC
78 MB
データパターン4
AC
77 MB