ソースコード
WITH BASE AS 
(
SELECT 
        A.PF_CODE,
        A.DISTRICT_CODE,
        A.BASE_CODE,
        A.LATITUDE ,
        A.LONGITUDE,
        B.LATITUDE AS BASELA,
        B.LONGITUDE AS BASELO
FROM
(
    SELECT
        PF_CODE,
        DISTRICT_CODE,
        '1101' AS BASE_CODE,
        LATITUDE ,
        LONGITUDE 
    FROM
        LOCATION_TBL
) A
LEFT JOIN 
(
    SELECT
        DISTRICT_CODE,
        LATITUDE ,
        LONGITUDE 
    FROM
        LOCATION_TBL
    WHERE
        DISTRICT_CODE = '1101'
) B
ON A.BASE_CODE = B.DISTRICT_CODE
)
SELECT
    LOC.DISTRICT_CODE AS CODE,
    DIS.DISTRICT_NAME AS NAME,
    LOC.LATITUDE AS LAT,
    LOC.LONGITUDE AS LON
FROM
    (
    SELECT
        PF_CODE,
        DISTRICT_CODE ,
        LATITUDE,
        LONGITUDE,
        ((LATITUDE - BASELA) * (LATITUDE - BASELA) + 
             (LONGITUDE - BASELO) * (LONGITUDE - BASELO) ) LEN
    FROM
        BASE
    WHERE
        DISTRICT_CODE <> '1101'
    ) LOC
    LEFT JOIN DISTRICT DIS
    ON LOC.DISTRICT_CODE = DIS.DISTRICT_CODE
ORDER BY
    LEN DESC
;
提出情報
提出日時2023/04/17 17:28:43
コンテスト第6回 SQLコンテスト
問題位置情報
受験者tanaka
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量93 MB
メッセージ
テストケース(通過数/総数)
2/3
状態
メモリ使用量
データパターン1
AC
93 MB
データパターン2
WA
78 MB
データパターン3
AC
91 MB