ソースコード
with dist as (
    select
        b.district_code
        , D.district_name
        , b.latitude
        , b.longitude
        -- , (
        -- 6371 * ACOS(
        -- COS(RADIANS(a.latitude)) * COS(RADIANS(b.latitude)) * COS(RADIANS(b.longitude) - RADIANS(a.longitude))
        -- + SIN(RADIANS(a.latitude)) * SIN(RADIANS(b.latitude))
        -- )
        -- ) as distance
        , sqrt(power(b.latitude - a.latitude, 2) + power(b.longitude - a.longitude, 2)) as distance
    from (
        select
            district_code
            , latitude
            , longitude
        from location_tbl
        where district_code = '1101'
    ) as a
    inner join location_tbl as b
        on a.district_code <> b.district_code
    inner join district as D
        on b.district_code = D.district_code
), format as (
    select
        district_code
        , district_name
        , latitude
        , longitude
        , distance
        , rank() over (order by distance desc) as rank
    from dist
)
select
    district_code as CODE
    , district_name as NAME
    , latitude as LAT
    , longitude as LON
from format
order by rank, district_code
;
提出情報
提出日時2023/04/15 22:53:29
コンテスト第6回 SQLコンテスト
問題位置情報
受験者s4wara_o
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
79 MB
データパターン2
AC
81 MB
データパターン3
AC
86 MB