Data is stored in my table is follows;
id Date user option
12345 09/26/2016 serv Y
12345 09/26/2016 serv N
How do I select the record where option = Y? If there is no record equal to Y, return the record = N
Data is stored in my table is follows;
id Date user option
12345 09/26/2016 serv Y
12345 09/26/2016 serv N
How do I select the record where option = Y? If there is no record equal to Y, return the record = N
create table #ertweety(d int not null, Date datetime, [user] varchar(50), [option] char(1))
insert into #ertweety
select '12345', '09/26/2016', 'serv', 'Y' union
select '12345', '09/26/2016', 'serv', 'N'
if not exists (select 1 from #ertweety where [option] = 'Y')
begin
select * from #ertweety where [option] = 'N'
end
else
begin
select * from #ertweety where [option] = 'Y'
end
drop table #ertweety
Doesn't seem to work for me. I should have stated I'm using pl/sql in an oracle environment.
this forum is for microsoft sql server