Solved

How do I perform mathematical update from fields using select statement

Posted on 2012-03-13
2
326 Views
Last Modified: 2012-03-13
I would like be able to update multiple fields with a mathematical function. For example in this example query I would like each field to be 76% of the original fields value.

select CHARGE from SHCOSTS where COST_CODE='R'and L_WEIGHT < 5.001
which output's


5.490
5.840
5.930
6.070
6.250
5.830
6.220
6.490
6.680
6.770
5.940
6.740
7.080
7.440
7.750
6.200
6.880
7.300
7.780
8.090
6.490
7.260
7.690
8.070
8.390
6.580
7.410
7.900
8.420
8.780
6.690
7.660
8.460
9.060
9.540
20.620
22.900
24.930
27.220
29.590
5.020
5.070
5.100
5.160
5.200
20.620
22.900
24.930
27.220
29.590
5.090
5.140
5.170
5.230
5.290
7.830
8.460
9.940
11.190
12.720
8.070
8.700
10.210
11.800
13.410
14.150
15.400
15.950
17.050
18.150
22.250
23.400
24.600
25.750
26.550
7.830
8.460
9.940
11.190
12.720
8.070
8.700
10.210
11.800
13.410
0
Comment
Question by:elusivedisc
2 Comments
 
LVL 9

Accepted Solution

by:
macarrillo1 earned 500 total points
ID: 37715650
Try:

update SHCOSTS
set CHARGE = CHARGE *0.76
where COST_CODE='R'and L_WEIGHT < 5.001
0
 

Author Closing Comment

by:elusivedisc
ID: 37715873
Worked perfect thank you.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Using MERGE to UPDATE a third table 14 37
SQL Server 2012 r2 Make faster Temp Table 17 103
get column names from table in vb.net 8 26
sql how to count case when 4 14
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question