Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Column Percentage Increase (x2)

Author  Topic 

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2009-01-12 : 11:20:56
Hi Experts,

I have a field which I wish to increase by 15% and 15% again.

So if we have 100, I want to end up with 100 + 15% + 15% = 132.25.

How can I do this in tsql?

I can get 15% obviously but not the subsequent percentage.
Any help would be really appreciated,
Barry



"Impossible is Nothing"

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-12 : 11:25:33
UPDATE table
SET field= field *(115.0/100.0)*(115.0/100.0)
Go to Top of Page

Skorch
Constraint Violating Yak Guru

300 Posts

Posted - 2009-01-12 : 12:33:17
DECLARE @percent INT, @value INT
SET @percent = 15.0
SET @value = 100.0
SELECT @value * POWER((@percent+100.0)/100,2)

So for your case you could do:
UPDATE YourField
SET YourField = YourField * POWER((15.0+100.0)/100,2)
Go to Top of Page
   

- Advertisement -