CREATE TABLE TABLERECS
(
id int primary key identity(1,1),
Empname nvarchar(20),
Empstatus nvarchar(20)
)
insert into TABLERECS values('John','ACT')
insert into TABLERECS values('Rob John','PEN')
insert into TABLERECS values('Little John','CAN')
insert into TABLERECS values('Flour John','CLO')
insert into TABLERECS values('rich John','TER')
insert into TABLERECS values('save John','ACP')
SELECT * FROM TABLERECS
create proc Test.dbo.test_check(@id int)
as
begin
select * from TABLERECS
where Empstatus IN (SELECT DISTINCT Empstatus from TABLERECS)
end
exec test_check 1
/** i tried my self but i think this is wrong . any one guide me.
/** 1. I write my Query above but when i pass id=1 i need show all records (all Status records)
/** 2. When pass greater then 1 ex : id=2 or 3 or 4 or 5 etc any one
/** I need show all reocrds ( but only Status PEN,CAN only
//* but i need single query no need if statment
//* i think we need case statement in the Empstatus . any one guide me
Mark as Answer if its helpful to you
Kumaraspcode2009@gmail.com