October 17, 2008 at 5:08 am
Morning, please forgive my ignorance, I am fairly unskilled beyond the basic SQL tasks, but I am adding to an existing application that I inherited with my role in the company I work for.
On a quotation Item table I want to add a computed column with the following formula ((([Price]-[QuotedCost])/[Price])*(100)). The Price column is of type float, the Quoted cost is decimal(5,2) and I would like the result to be accurate to 2 decimal places, how can I achieve this???
thanks
Mike
October 17, 2008 at 6:18 am
your going to be mad at yourself...you did everything except CAST/CONVERT your answer to the desired decimal:
create table test(
Price decimal(5,2),
QuotedCost decimal(5,2),
OrigCalc AS ([Price]-[QuotedCost])/[Price] *(100) ,
NewCalc AS CONVERT(DECIMAL(8,2),([Price]-[QuotedCost])/[Price] *(100)) )
Lowell
October 17, 2008 at 6:43 am
Lowell, thankyou...... works beautifully :o)
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply