Author: gopi007 | Posted on: 5/5/2010 6:04:39 AM | Views : 417

;with cte as
(select Sum(P.Qty over (partition by RefNo) - ISNULL( t.Qty,0) as Qty,ROW_NUMBER()
over (PARTITION by RefNo order by ID desc) as rn from dbo.purchase P
cross apply (select SUM(Qty) as Qty from dbo.sales where RefNo = P.RefNo)t
where RefNo in (select RefNo from dbo.Purchase ))
select * from cte where rn = 1
 
hi.. this code is working fine.. but my requirement is if itz return 0(Zero) on result set I don't want to show 0(Zero) Record.. plz help me
 
...

Go to the complete details ...