you dont need a cursor for this. what you need is just thisSELECT s.[SERVE_NO],t.Duration/60.0FROM Services sINNER JOIN(SELECT us.Serve_no,us.Duration FROM dbo.UsageSummary us INNER JOIN (SELECT Serve_no,MAX(ACC_HEADER) AS recent FROM dbo.UsageSummary WHERE CHARGE_CAT = 'airtime' GROUP BY Serve_no) us1 ON us1.Serve_no=us.Serve_no AND us1.recent=us.ACC_HEADER WHERE us.CHARGE_CAT = 'airtime')tON t.Serve_no=s.[SERVE_NO]where s.serv_type = 'cellphone' and s.LINE_STATUS = 'ACTIVE'