ソースコード
SELECT 
    s.AGE,
    CASE 
        WHEN s.GENDER_CODE = 20 THEN 'MALE'
        WHEN s.GENDER_CODE = 30 THEN 'FEMALE'
    END AS GENDER,
    s.H_AVG,
    COUNT(CASE WHEN s.CATEGORY_CODE = 10 AND s.AVERAGE_VALUE >= s.H_AVG THEN 1 END) / COUNT(*) * 100 AS H_PER,
    s.W_AVG,
    COUNT(CASE WHEN s.CATEGORY_CODE = 20 AND s.AVERAGE_VALUE >= s.W_AVG THEN 1 END) / COUNT(*) * 100 AS W_PER
FROM (
    SELECT 
        AGE, 
        GENDER_CODE, 
        CATEGORY_CODE,
        AVERAGE_VALUE,
        AVG(CASE WHEN CATEGORY_CODE = 10 THEN AVERAGE_VALUE ELSE NULL END) OVER (PARTITION BY AGE, GENDER_CODE) AS H_AVG,
        AVG(CASE WHEN CATEGORY_CODE = 20 THEN AVERAGE_VALUE ELSE NULL END) OVER (PARTITION BY AGE, GENDER_CODE) AS W_AVG
    FROM SURVEY
    WHERE SURVEY_YEAR = 2019
) s
GROUP BY s.AGE, s.GENDER_CODE, s.H_AVG, s.W_AVG
ORDER BY s.AGE DESC, s.GENDER_CODE DESC;



提出情報
提出日時2023/08/18 18:25:51
コンテスト第8回 SQLコンテスト
問題身長と体重
受験者imofessional
状態 (詳細)RE
(Runtime Error: 実行時エラー)
メモリ使用量85 MB
メッセージ
SQLITE_ERROR: no such table: SURVEY
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
RE
82 MB
データパターン2
RE
85 MB