We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Sql Update with Calculation

gfedz
gfedz asked
on
Medium Priority
453 Views
Last Modified: 2012-05-11
I need to do an update statement where 3 columns are multiplied together and stored into another column.  I'm not quite sure how to accomplish this.

 
UPDATE tblRequestHistory SET strPrintCost = (SUM(CONVERT(numeric(8, 4), strPrintCost) * intPages * intCopies)) WHERE strPrintCost IS NOT NULL

Open in new window


intPages and intCopies are stored in the tblRequestHistory.  strPrintCost is also in the table and has a cost already assigned to it.  I need to multiply these 3 fields together and overwrite the sum to strPrintCost.  
Comment
Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Ephraim WangoyaSoftware Engineer
CERTIFIED EXPERT

Commented:


UPDATE tblRequestHistory
SET strPrintCost = cast(CONVERT(numeric(8, 4), strPrintCost) * intPages * intCopies as varchar)
WHERE strPrintCost IS NOT NULL
Ephraim WangoyaSoftware Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
I'm still pretty new to syntax in sql.  I assumed it was something like this.  Thank you guys for your time.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.