ソースコード
WITH DUPLICATE_EMP AS (
    SELECT
        MIN(REMOVED.FULL_NAME) AS FULL_NAME
        , COUNT(REMOVED.FULL_NAME) AS CNT
    FROM
        (
            SELECT
                REPLACE(EMP_LAST_NAME, ' ', '') || REPLACE(EMP_FIRST_NAME, ' ', '')
                    AS FULL_NAME
            FROM
                EMP
            WHERE
                VALID_FLG = 1   -- 有効
        ) AS REMOVED
    GROUP BY
        REMOVED.FULL_NAME
    HAVING
        CNT > 1
)
, NAME_ORDERED AS (
    SELECT
        EMP_CODE AS CODE
        , EMP_LAST_NAME
        , EMP_FIRST_NAME
        , REPLACE(EMP_LAST_NAME, ' ', '') AS LM_REMOVED
        , REPLACE(EMP_FIRST_NAME, ' ', '') AS FN_REMOVED
    FROM
        EMP
    WHERE
        VALID_FLG = 1   -- 有効
    ORDER BY
        LM_REMOVED ASC
        , FN_REMOVED ASC
        , CODE ASC
)
SELECT
    CODE
    , EMP_LAST_NAME AS SURNAME
    , EMP_FIRST_NAME AS NAME
FROM
    NAME_ORDERED
WHERE
    LM_REMOVED || FN_REMOVED
    IN (
        SELECT
            FULL_NAME
        FROM
            DUPLICATE_EMP
    )
;
提出情報
提出日時2024/01/29 12:13:56
コンテスト第5回 SQLコンテスト
問題同姓同名抽出
受験者maori
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量84 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
84 MB
データパターン3
AC
84 MB