Join Table with Division

Hi all
I have two tables


please help me how to make result like that

Create table #A (id int, Unit char(1), Conv int)
Create table #B (id int, Qty int)

insert into #A values

insert into #B values (1,223)
Select ID, Unit, Conv, IsNull(Remainder, Division) Division
from (
select a.ID, a.Unit, a.Conv, qty / Conv as division,
(lag(qty - (qty / Conv * Conv)) over (order by Conv desc)/Conv) as Remainder
from #A a
join #B b
on a.ID = b.ID
) x
order by Conv desc


Thank bro....
but I am using sql server 2005 and lag function not support, please help me