ソースコード
with avg_point as (
    select
        test_id,
        avg(point) as avg_point
    from test_results
    where test_id = 100
    group by 1)

select
    aaa.user_id as USER,
    aaa.point as PT,
	case when bbb.sqrt_pow_avg = 0 then 50
	else
    round((50 + (10 * (aaa.point - ccc.avg_point) / bbb.sqrt_pow_avg)), 1)
	end as DEV_VAL
from test_results as aaa
inner join (
    select
        bb.test_id,
        pow(bb.pow_avg, 0.5) as sqrt_pow_avg
    from(
        select
            a.test_id,
            avg(pow(cast(a.point as real) - b.avg_point, 2)) as pow_avg
        from test_results as a
        inner join avg_point as b
        using (test_id)
        group by 1) as bb
        ) as bbb
using(test_id)
inner join avg_point as ccc
using(test_id)
order by 3 desc, 1 asc;
提出情報
提出日時2023/05/30 11:03:27
コンテスト第5回 SQLコンテスト
問題偏差値の算出
受験者miotsukushi0800
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量76 MB
メッセージ
テストケース(通過数/総数)
4/4
状態
メモリ使用量
データパターン1
AC
76 MB
データパターン2
AC
76 MB
データパターン3
AC
76 MB
データパターン4
AC
76 MB