declare @t as table(Id int, Name varchar(3)); insert int...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

declare @t as table(Id int, Name varchar(3));

insert into @t(id, Name)
select 1, 'DEF' union all
select 2, 'ABC' union all
select 3, 'DEF' union all
select 4, 'XYZ' union all
select 5, 'XYZ';

--select distinct Name from @t;

--select Name, count(*) as cnt
--from @t
--group by Name
--having count(*) > 1

select * from @t as t1
where exists(
  select  1 from (
    select name from @t
    group by name
    having count(*) = 1
  ) as t2
    where t1.name = t2.name
);

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results