Reduce data in a column by half?

phentop's profile image phentop posted 2 years ago in General Permalink

Is there a way to reduce all the data in a column by half?

For example: If I had the following starting data in each line

1000

1000

1000

500

500

400

200

But I wanted that data in each line to be reduced by half

500

500

500

250

250

200

100

Is there a query command to complete this request?

ansgar's profile image ansgar posted 2 years ago Permalink

I'd say:

UPDATE mytable SET colx = colx / 2;

Note this will probably create problems if the value is not dividable by 2. But there's just too few technical details in your post.

phentop's profile image phentop posted 2 years ago Permalink

This worked for me! No issues created.

Please login to leave a reply, or register at first.