Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old August 7th, 2008, 07:25 PM
Newbie
 
Join Date: Aug 2008
Location: Brighton, South Coast, UK
Age: 41
Posts: 4
Default Newbie is stuck! How do I increase a cost by a percentage?

Hi - currently training on SQL - doing alright so far until this sub-question...

Migrate all data from the JOB_COST table into the TOTAL_COST table. For those records that match the COST_ID, update the UPPER_LEVEL and increase the cost by 15%, otherwise insert the records.

...I've looked everywhere online but have no luck. How do I increase a cost by a percentage? Please?
Reply
  #2  
Old August 7th, 2008, 10:36 PM
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Age: 22
Posts: 2,790
Default

Hi.

Basic math... you multiply by 1.15 ;)
Expand|Select|Wrap|Line Numbers
  1. SELECT numericField * 1.15
  2.  
Should return the values of that field + 15%;

If you are getting any rounding issues (which you shouldn't), you can CAST it to Decimal
Expand|Select|Wrap|Line Numbers
  1. SELECT CAST(numericField AS Decimal) * 1.15
  2.  
Reply
  #3  
Old August 7th, 2008, 10:52 PM
Newbie
 
Join Date: Aug 2008
Location: Brighton, South Coast, UK
Age: 41
Posts: 4
Default

Quote:
Originally Posted by Atli
Hi.

Basic math... you multiply by 1.15 ;)
Expand|Select|Wrap|Line Numbers
  1. SELECT numericField * 1.15
  2.  
Should return the values of that field + 15%;

If you are getting any rounding issues (which you shouldn't), you can CAST it to Decimal
Expand|Select|Wrap|Line Numbers
  1. SELECT CAST(numericField AS Decimal) * 1.15
  2.  
Duh! :-) There was me expecting something long and complicated!

Thanks Atli - much appreciated!
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles