update vs4tinventorymb set tinmunitratio =(select timcunitratio from vs4tinventorylot where vs4tinventorylot.timctpdtcode=vs4tinventorymb.tinmtpdtcode and vs4tinventorylot.timclotno=vs4tinventorymb.tinmlotno and vs4tinventorylot.timccustom1=vs4tinventorymb.tinmcustom1 and vs4tinventorylot.timcserialno=vs4tinventorymb.tinmserialno and vs4tinventorylot.timclotdate=vs4tinventorymb.tinmlotdate)
GO
update vs4tinventorymb set tinmunitratio =1 where tinmunitratio is null
GO
update vs4tinventorymb set tinmquantitybase = -1*abs(tinmamouquantity/tinmunitratio) where tinmamouquantity<0
GO
update vs4tinventorymb set tinmquantitybase = 1*abs(tinmamouquantity/tinmunitratio) where tinmamouquantity>=0
GO