Skip to content

Instantly share code, notes, and snippets.

@yssymmt
Last active March 16, 2022 16:27
Show Gist options
  • Save yssymmt/937cd8c1c60f73a282969fac652a594a to your computer and use it in GitHub Desktop.
Save yssymmt/937cd8c1c60f73a282969fac652a594a to your computer and use it in GitHub Desktop.
with src as (
select
製品番号,
製品名称
from データベース名.テーブル名
group by 1,2
)
, idchk as (
select
製品番号
from データベース名.テーブル名
group by 1
having count(*) >1
)
, descchk as (
select
製品名称
from データベース名.テーブル名
group by 1
having count(*) >1
)
select
製品番号,
製品名称
from src
where 製品番号 in (
select 製品番号 from idchk
) or 製品名称 in (
select 製品名称 from descchk
)
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment