ソースコード
SELECT
PR.PF_CODE AS "都道府県コード",
PR.PF_NAME AS "都道府県名",
NA.NATION_NAME AS "1位 国名",
FO1.AMT AS "1位 人数",
NA.NATION_NAME AS "2位 国名",
FO2.AMT AS "2位 人数",
NA.NATION_NAME AS "3位 国名",
FO3.AMTAS "3位 人数",
SUM(FO.AMT) AS "合計人数"
FROM 
PREFECTURE AS PR
INNER JOIN FOREIGNER AS FO ON PR.PF_CODE = FO.PF_CODE
INNER JOIN (SELECT PF_CODE, AMT FROM FOREIGNER AS f1 WHERE PR.PF_CODE = f1.PF_CODE ORDER BY f1.AMT ASC, PF_CODE ASC LIMIT 1, 0) AS FO1 ON PR.PF_CODE = FO1.PF_CODE
INNER JOIN (SELECT PF_CODE, AMT FROM FOREIGNER AS f2 WHERE PR.PF_CODE = f2.PF_CODE ORDER BY f2.AMT ASC, PF_CODE ASC LIMIT 1, 1)  AS FO2 ON PR.PF_CODE = FO2.PF_CODE
INNER JOIN (SELECT PF_CODE, AMT FROM FOREIGNER AS f3 WHERE PR.PF_CODE = f3.PF_CODE ORDER BY f3.AMT ASC, PF_CODE ASC LIMIT 1, 2)  AS FO3 ON PR.PF_CODE = FO3.PF_CODE
INNER JOIN NATIONALITY AS NA ON NA.NATION_CODE = FO.NATION_CODE
WHERE NA.NATION_CODE != '113'
GROUP BY PR.PF_CODE
ORDER BY
"合計人数" DESC,
PR.PF_CODE ASC;
提出情報
提出日時2022/07/20 20:51:09
コンテスト第1回 SQLコンテスト
問題外国籍分布
受験者tajima
状態 (詳細)RE
(Runtime Error: 実行時エラー)
メモリ使用量101 MB
メッセージ
SQLITE_ERROR: no such column: PR.PF_CODE
テストケース(通過数/総数)
0/2
状態
メモリ使用量
データパターン1
RE
98 MB
データパターン2
RE
101 MB