ソースコード
SELECT
  EMP2.EMP_CODE AS CODE,
  EMP2.EMP_LAST_NAME AS SURNAME,
  EMP2.EMP_FIRST_NAME AS "NAME"
FROM
  (
  SELECT
    EMP_FIRST_NAME,
    EMP_LAST_NAME,
    COUNT(EMP_FIRST_NAME),
    COUNT(EMP_LAST_NAME)
  FROM
    (
      SELECT 
        REPLACE(EMP_FIRST_NAME, ' ', '') AS EMP_FIRST_NAME,
        REPLACE(EMP_LAST_NAME, ' ', '') AS EMP_LAST_NAME
      FROM 
        EMP
      WHERE
        VALID_FLG = 1
    )
  GROUP BY
    EMP_FIRST_NAME, EMP_LAST_NAME
  HAVING
    COUNT(EMP_FIRST_NAME) > 1
    AND COUNT(EMP_LAST_NAME) > 1
  ) AS CNT
  INNER JOIN (
    SELECT
      EMP_CODE,
      EMP_LAST_NAME,
      EMP_FIRST_NAME,
      REPLACE(EMP_FIRST_NAME, ' ', '') AS EMP_FIRST_NAME2,
      REPLACE(EMP_LAST_NAME, ' ', '') AS EMP_LAST_NAME2
    FROM EMP
    WHERE
        VALID_FLG = 1
  ) AS EMP2 ON EMP2.EMP_FIRST_NAME2 = CNT.EMP_FIRST_NAME AND EMP2.EMP_LAST_NAME2 = CNT.EMP_LAST_NAME
ORDER BY
  EMP_LAST_NAME2,
  EMP_FIRST_NAME2,
  EMP_CODE
提出情報
提出日時2023/02/19 16:24:45
コンテスト第5回 SQLコンテスト
問題同姓同名抽出
受験者chappie
状態 (詳細)AC
(Accepted: 正答)
メモリ使用量94 MB
メッセージ
テストケース(通過数/総数)
3/3
状態
メモリ使用量
データパターン1
AC
94 MB
データパターン2
AC
92 MB
データパターン3
AC
88 MB