Solve your biggest tech problems alongside global tech experts with 1:1 help.
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
select key_id, a, case when b = 0 then 0 else a/b end x