Getting a percentage

October 3rd, 2008 by Mr.M | No Comments »

An annoying friend of mine and I was talking about percentage gain in stocks. I was damn good at math when I was in middle school but once I got to high school, I could care less. I take classes like Algebra, Geometry, Calculus and Trig. I passed them with either a ‘B’ or a ‘C’ depending on how much effort I put into it. I’ve never really been an ‘A’ seeking person, school is just a stepping stone and everyone knows that schooling can only prepare you for so much.

Anyways, I had some trouble figuring out the percentage gain of a stock but ex co-worker provide a very simple formula: (new$/old$)-1. Today, I needed to use that formula again and decided to stick it in a piece of code in SQL :) .

declare @start_value float, @new_value float

set @start_value = 1.80
set @new_value = 6.10

select ((@new_value / @start_value) - 1) * 100

Leave a Reply

You must be logged in to post a comment.