Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

Mulpliplcation of all values in a column plus converting negative values

Question posted by: bengevik (Newbie) on July 3rd, 2008 07:23 PM
I need to multiplicate all the values in a coloumn with a constant and returning them in a (eventually new) column.

My second problem is that there are negative values in some rows. I need to convert these values in this way:
6,28 - (value)
into positive values.

Is there any functions for these operations and how will it look like?
Delerna's Avatar
Delerna
Expert
557 Posts
July 4th, 2008
02:57 AM
#2

Re: Mulpliplcation of all values in a column plus converting negative values
Multiply by a constant
Expand|Select|Wrap|Line Numbers
  1. select 6*Field1,12*Field2
  2. From yourtable


Field sometimes negative
Expand|Select|Wrap|Line Numbers
  1. select case when Field1<0 then 3200-Field1 else 6*Field1 end as Field1
  2. From YourTable

Reply
ck9663's Avatar
ck9663
Expert
1,352 Posts
July 4th, 2008
06:10 AM
#3

Re: Mulpliplcation of all values in a column plus converting negative values
You can also use this function.

Happy coding.

-- CK

Reply
bengevik's Avatar
bengevik
Newbie
2 Posts
July 4th, 2008
12:19 PM
#4

Re: Mulpliplcation of all values in a column plus converting negative values
Danke sehr.

I do have one more problem: how can I convert a text field containing only numbers to a number field?

Reply
Delerna's Avatar
Delerna
Expert
557 Posts
July 7th, 2008
01:08 AM
#5

Re: Mulpliplcation of all values in a column plus converting negative values
the function "convert" is used to convert fields from one data type to another in a query. Check the help files

Reply
Reply
Not the answer you were looking for? Post your question . . .
189,759 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top Microsoft SQL Server Contributors