ソースコード
WITH CleanedEmp AS (
    SELECT
        EMP_CODE AS CODE,
        REPLACE(EMP_LAST_NAME, ' ', '') AS CLEANED_LAST_NAME,
        REPLACE(EMP_FIRST_NAME, ' ', '') AS CLEANED_FIRST_NAME,
        EMP_LAST_NAME AS SURNAME,
        EMP_FIRST_NAME AS NAME
    FROM
        EMP
    WHERE
        VALID_FLG = '1'
),
DuplicateNames AS (
    SELECT
        CLEANED_LAST_NAME,
        CLEANED_FIRST_NAME
    FROM
        CleanedEmp
    GROUP BY
        CLEANED_LAST_NAME,
        CLEANED_FIRST_NAME
    HAVING
        COUNT(*) > 1
)
SELECT
    e.CODE,
    e.SURNAME,
    e.NAME
FROM
    CleanedEmp e
JOIN
    DuplicateNames d
    ON e.CLEANED_LAST_NAME = d.CLEANED_LAST_NAME
    AND e.CLEANED_FIRST_NAME = d.CLEANED_FIRST_NAME
ORDER BY
    e.CLEANED_LAST_NAME,
    e.CLEANED_FIRST_NAME,
    e.CODE;
提出情報
提出日時2024/09/19 15:55:33
コンテスト第5回 SQLコンテスト
問題同姓同名抽出
受験者lulei
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量86 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
84 MB
データパターン2
AC
86 MB
データパターン3
AC
85 MB