February 24, 2011 at 9:02 am
I like to display one decimal point with the result division.
For example, 7/12 = 58.3%
How to use dec function?
February 24, 2011 at 9:22 am
Try this:
DECLARE @A DECIMAL(5,0)
DECLARE @B DECIMAL(5,0)
DECLARE @P DECIMAL(3,0)
DECLARE @Ans DECIMAL(5,1)
SET @A = 7.
SET @B = 12.
SET @P = 100.
SELECT ROUND((@A/@B) * @P,1)
--If you just wish to display the resutl:
--that is NO further mathametical work
SELECT SUBSTRING(CAST(ROUND((@A/@B) * @P,1) AS VARCHAR(10)),1,CHARINDEX('.',ROUND((@A/@B) * @P,1),1)+1)+ '%'
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply