Need expert helpâ€”fast? Use the Help Bell for personalized assistance getting answers to your important questions.
create table #a ( ident int identity, a int,b int)
insert into #a (a,b)
select n, case when n%10000=0 then 0 else case when n%300=0 then 2 else n/2 end end
from vw_nums
where n < 500000
select ident,a,b,a/b from #a
where b<>0 and b is not null
select ident,a,b,a/b from #a
where ident in (select ident from #a where b <> 0 and b is not null)
go
drop table #a
create table #a ( ident int identity, a int,b int)
insert into #a (a,b)
select n, case when n%10000=0 then 0 else case when n%300=0 then 2 else n/2 end end
from vw_nums
where n < 500000
select ident,a,b,a/b from #a
where b<>0 and b is not null
select ident,a,b,a/b from #a
where ident in (select ident from #a where b <> 0 and b is not null)
select ident,a/b from #a
where b<>0 and b is not null
select ident,a/b from #a
where ident in (select ident from #a where b <> 0 and b is not null)
go
drop table #a
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
select key_id, a, case when b = 0 then 0 else a/b end x