ソースコード
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,
        SQRT((CAST(LATITUDE AS REAL) - CAST(BASELA AS REAL)) * (CAST(LATITUDE AS REAL) - CAST(BASELA AS REAL)) + 
             (CAST(LONGITUDE AS REAL) - CAST(BASELO AS REAL)) * (CAST(LONGITUDE AS REAL) - CAST(BASELO AS REAL)) ) 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/14 21:25:14
コンテスト第6回 SQLコンテスト
問題位置情報
受験者tanaka
状態 (詳細)WA
(Wrong Answer: 誤答)
メモリ使用量81 MB
メッセージ
テストケース(通過数/総数)
2/3
状態
メモリ使用量
データパターン1
AC
79 MB
データパターン2
WA
81 MB
データパターン3
AC
80 MB