tsql - Finding the least of three is working great, but how do I save the value to my table for each row? -



tsql - Finding the least of three is working great, but how do I save the value to my table for each row? -

declare @leastof3 numeric begin tran select item#, id, market, lifo, wgtd_avg, ( case when market = wgtd_avg , wgtd_avg = lifo market when lifo = 0 , wgtd_avg = 0 , market <> 0 market when market < lifo , market < wgtd_avg , market <> 0 market when market <= wgtd_avg , lifo = 0 market when market <= lifo , wgtd_avg = 0 market when market = 0 , wgtd_avg = 0 , lifo <> 0 lifo when lifo < market , lifo < wgtd_avg , lifo <> 0 lifo when lifo <= market , wgtd_avg = 0 lifo when lifo <= wgtd_avg , market = 0 lifo when market = 0 , lifo = 0 , wgtd_avg <> 0 wgtd_avg when wgtd_avg < market , wgtd_avg < lifo , wgtd_avg <> 0 wgtd_avg when wgtd_avg <= market , lifo = 0 wgtd_avg when wgtd_avg <= lifo , market = 0 wgtd_avg when market <= lifo , lifo < wgtd_avg , market <> 0 market when lifo <= market , market < wgtd_avg , lifo <> 0 lifo when wgtd_avg <= lifo , lifo < market , wgtd_avg <> 0 wgtd_avg else 0 end ) leastof3 vf_casinv_cost (calendaryear = 2010) , (item# < 99999990) --set leastofthree = leastof3 --update vf_casinv_cost --set leastofthree = @leastof3 --where (calendaryear = 2010) , (item# = item#) , (id = id) , (item# < 99999990) --go

use update statement, sort of this:

update vf_casinv_cost set leastofthree = leastof3 select (... big select statement...)

tsql

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -