select key_id, a, case when b = 0 then 0 else a/b end x
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
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
21 Experts available now in Live!