situation is that need to get records that have only "1" in 2nd column. If they have any other value other than "1", need to ignore all records for particular 1st column.
can you plz suggest a query
drop table if exists #Temp
create table #Temp ( col1 varchar(20) , col2 int )
insert into #Temp select 'asdf',1
insert into #Temp select 'asdf',2
insert into #Temp select 'asdf',3
insert into #Temp select 'kjhj',1
insert into #Temp select 'qwer',1
insert into #Temp select 'qwer',1
;WITH cte AS
(
SELECT
col1
, case when min(col2) = max(col2) then 1 end as col2
FROM
#Temp
GROUP BY
col1
)
SELECT
*
FROM
CTE
WHERE
col2 is not null