ソースコード
WITH
Calc_avg
(
    test_code
    ,subject_code
    ,T_SCORE
    ,C_SUB
    ,AVG
)
AS
(
    SELECT
        test_code
        ,subject_code
        ,SUM(score) AS T_SCORE
        ,COUNT(*)  AS C_SUB
        ,SUM(score) / COUNT(*)  AS AVG
    FROM scores
    GROUP BY
         test_code
        ,subject_code
),
Calc_exam
(
    test_code
    ,student_code
    ,subject_code
    ,score
    ,ranking
    ,passed
)
AS
(
    SELECT
         SC.test_code
        ,SC.student_code
        ,SC.subject_code
        ,SC.score
        ,SC.ranking
        ,CASE WHEN score >= CA.AVG THEN TRUE ELSE FALSE END AS passed
    FROM scores AS SC
    LEFT JOIN Calc_avg AS CA ON SC.test_code = CA.test_code AND SC.subject_code = CA.subject_code
)

SELECT * FROM Calc_exam;

提出情報
提出日時2024/05/27 14:17:21
コンテストSQLの教科書確認用コンテスト4
問題副問合せの結果で絞り込み2
受験者satoru
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量102 MB
メッセージ
テストケース(通過数/総数)
0/3
状態
メモリ使用量
データパターン1
WA
91 MB
データパターン2
WA
93 MB
データパターン3
WA
102 MB