ソースコード
WITH avg_points AS (
  SELECT USER_ID, AVG(POINT) AS AVG_POINT
  FROM TEST_RESULTS
  WHERE TEST_ID = '100'
  GROUP BY USER_ID
),
std_dev AS (
  SELECT USER_ID, 
         SQRT(SUM((POINT - AVG_POINT) * (POINT - AVG_POINT)) / COUNT(*)) AS STD_DEV
  FROM TEST_RESULTS
  JOIN avg_points ON TEST_RESULTS.USER_ID = avg_points.USER_ID
  WHERE TEST_ID = '100'
  GROUP BY USER_ID
)
SELECT t.USER_ID AS USER, t.POINT AS PT, 
       CASE WHEN s.STD_DEV = 0 THEN 50
            ELSE ROUND((t.POINT - a.AVG_POINT) * 10 / s.STD_DEV + 50, 1)
       END AS DEV_VAL
FROM TEST_RESULTS AS t
JOIN avg_points AS a ON t.USER_ID = a.USER_ID
JOIN std_dev AS s ON t.USER_ID = s.USER_ID
WHERE t.TEST_ID = '100'
ORDER BY DEV_VAL DESC, t.USER_ID ASC;
提出情報
提出日時2023/07/13 13:50:57
コンテスト第5回 SQLコンテスト
問題偏差値の算出
受験者fish_man
状態 (詳細)RE
(Runtime Error: 実行時エラー)
メモリ使用量80 MB
メッセージ
SQLITE_ERROR: ambiguous column name: USER_ID
テストケース(通過数/総数)
0/4
状態
メモリ使用量
データパターン1
RE
80 MB
データパターン2
RE
78 MB
データパターン3
RE
79 MB
データパターン4
RE
80 MB