declare @l_wkqty numeric(14,4)
select
    @l_wkqty =sum(a.wkqty)
from
    (select wkqty = round((h.inputqty + h.rtnqty + c.balqty * c.finrate / 100) * 
            (case when m.cst_grpno = 'SFC' then i.varover when m.cst_grpno <> 'SFC' then (select cm.varover from cst_mom10109 cm where m.cst_grpno = cm.grpno) end),4))
     from dbo.cos20140 h holdlock,
          dbo.cos20110 c holdlock,
          dbo.mom10200 m holdlock,
          dbo.inv10100 i
     where h.year = 2005 and
           h.month = 10 and
           h.code = 'M' and
           c.year = h.year and
           c.month = h.month and
           m.no = h.docno and
           m.seq = h.seq  and
           c.mo = h.docno and
           c.seq = h.seq and
           i.part = h.part 
     --group by h.year, h.month
     ) a
select str(@l_wkqty)