ソースコード

select * FROM 
-- H_AVG
    (select 
    AGE, 
    CASE WHEN GENDER_CODE = 20 THEN 'MALE' ELSE 'FEMALE' END AS GENDER,
    ROUND(AVG(AVERAGE_VALUE), 1) AS H_AVG
    FROM SCHOOL_HEALTH
    WHERE SURVEY_YEAR = 2019
    AND CATEGORY_CODE = 10
    GROUP BY AGE, GENDER_CODE
    ORDER BY AGE DESC, GENDER_CODE DESC) AS AAA
-- H_PER
JOIN 
    (select  
    AGE, 
    CASE WHEN GENDER_CODE = 20 THEN 'MALE' ELSE 'FEMALE' END AS GENDER,
    COUNT( 
    case when 
        AVERAGE_VALUE >= (SUM(AVERAGE_VALUE) / COUNT(AVERAGE_VALUE))
        then true
        else null
        end
    ) AS H_PER
    FROM SCHOOL_HEALTH
    WHERE SURVEY_YEAR = 2019
    AND CATEGORY_CODE = 10
    GROUP BY AGE, GENDER_CODE
    ORDER BY AGE DESC, GENDER_CODE DESC) AS AAA_1
ON AAA.AGE = AAA_1.AGE
AND AAA.GENDER = AAA_1.GENDER

-- W_AVG
JOIN 
    (select  
    AGE, 
    CASE WHEN GENDER_CODE = 20 THEN 'MALE' ELSE 'FEMALE' END AS GENDER,
    ROUND(AVG(AVERAGE_VALUE), 1) AS W_AVG
    FROM SCHOOL_HEALTH
    WHERE SURVEY_YEAR = 2019
    AND CATEGORY_CODE = 20
    GROUP BY AGE, GENDER_CODE
    ORDER BY AGE DESC, GENDER_CODE DESC) AS BBB
ON AAA.AGE = BBB.AGE
AND AAA.GENDER = BBB.GENDER
提出情報
提出日時2023/08/19 08:07:04
コンテスト第8回 SQLコンテスト
問題身長と体重
受験者KakiageSeiro
状態 (詳細)RE
(Runtime Error: 実行時エラー)
メモリ使用量79 MB
メッセージ
SQLITE_ERROR: misuse of aggregate function COUNT()
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
RE
76 MB
データパターン2
RE
79 MB