Rafael Sabadin
Rafael Sabadin

Reputation: 1

Divide by from selected columns

Sorry if the question was asked before i try search but not found. I'm still new on mssql so maybe the answer are obvious just i cant find.

My current query is:

SELECT gold_min, gold_max, gold_min_2, gold_max_2
FROM m_rdb

I want to divide the values on current columns by 20 and then update, just not sure how to do. Any help are welcome.

Upvotes: 0

Views: 136

Answers (2)

andy
andy

Reputation: 6079

If your updating the values to same columns then

Update m_rdb SET gold_min = gold_min/20, gold_max=gold_max/20,
gold_min_2=gold_min_2/20, gold_max_2=gold_max_2/20

If your updating the values to Other columns then

Update m_rdb SET gold_min_other = gold_min/20, gold_max_other=gold_max/20,
gold_min_2_other=gold_min_2/20, gold_max_2_other=gold_max_2/20

Upvotes: 0

Joe G Joseph
Joe G Joseph

Reputation: 24046

Are you looking for this:

update m_rdb
set col=col/20.0

Upvotes: 1

Related Questions