
declare @t table(id
int identity(
1,
1), v varchar(
10))

insert @t select
'
a
'

union all select
'
b
'

union all select
'
c
'

union all select
'
d
'

union all select
'
e
'

union all select
'
b
'

union all select
'
c
'

--a語句in的sql寫法

select * from @t
where v
in (select v from @t group by v having count(*)>
1)

--b語句exists的sql寫法

select * from @t a
where exists(select
1 from @t
where id!=a.id and v=a.v)