ソースコード
SELECT
  AGE AS 'AGE'
 ,CASE
    WHEN GENDER_CODE = '20' THEN 'MALE'
    WHEN GENDER_CODE = '30' THEN 'FEMALE'
  END AS 'GENDER'
 ,(SELECT ROUND(AVG(B.AVERAGE_VALUE),1) FROM SCHOOL_HEALTH B WHERE B.SURVEY_YEAR = 2019 AND B.AGE = A.AGE AND B.GENDER_CODE = A.GENDER_CODE AND B.CATEGORY_CODE = '10') AS 'H_AVG'
-- ,
 cast(( SELECT COUNT(*) FROM SCHOOL_HEALTH C WHERE C.SURVEY_YEAR = 2019 AND C.AGE = A.AGE AND C.GENDER_CODE = A.GENDER_CODE AND C.CATEGORY_CODE = '10' AND 
 AVERAGE_VALUE >= (SELECT ROUND(AVG(B.AVERAGE_VALUE),1) FROM SCHOOL_HEALTH B WHERE B.SURVEY_YEAR = 2019 AND B.AGE = A.AGE AND B.GENDER_CODE = A.GENDER_CODE AND CATEGORY_CODE = '10')),REAL)
 /
 cast((SELECT COUNT(*) FROM SCHOOL_HEALTH D WHERE D.SURVEY_YEAR = 2019 AND D.AGE = A.AGE AND D.GENDER_CODE = A.GENDER_CODE AND D.CATEGORY_CODE = '10'),REAL) * 100
 AS 'H_PER'

 ,(SELECT ROUND(AVG(B.AVERAGE_VALUE),1) FROM SCHOOL_HEALTH B WHERE B.SURVEY_YEAR = 2019 AND B.AGE = A.AGE AND B.GENDER_CODE = A.GENDER_CODE AND B.CATEGORY_CODE = '20') AS 'W_AVG'
 cast(( SELECT COUNT(*) FROM SCHOOL_HEALTH C WHERE C.SURVEY_YEAR = 2019 AND C.AGE = A.AGE AND C.GENDER_CODE = A.GENDER_CODE AND C.CATEGORY_CODE = '20' AND 
 AVERAGE_VALUE >= (SELECT ROUND(AVG(B.AVERAGE_VALUE),1) FROM SCHOOL_HEALTH B WHERE B.SURVEY_YEAR = 2019 AND B.AGE = A.AGE AND B.GENDER_CODE = A.GENDER_CODE AND CATEGORY_CODE = '20')),REAL)
 /
 cast((SELECT COUNT(*) FROM SCHOOL_HEALTH D WHERE D.SURVEY_YEAR = 2019 AND D.AGE = A.AGE AND D.GENDER_CODE = A.GENDER_CODE AND D.CATEGORY_CODE = '20'),REAL) * 100
 AS 'H_PER'
FROM SCHOOL_HEALTH A
WHERE
  SURVEY_YEAR = 2019
GROUP BY AGE, GENDER
ORDER BY
  AGE DESC
  ,GENDER_CODE DESC
提出情報
提出日時2023/08/21 10:28:52
コンテスト第8回 SQLコンテスト
問題身長と体重
受験者YSSunDZ
状態 (詳細)RE
(Runtime Error: 実行時エラー)
メモリ使用量85 MB
メッセージ
SQLITE_ERROR: near "cast": syntax error
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
RE
85 MB
データパターン2
RE
84 MB