October 21, 2009 at 1:15 am
Hi All
i an having this issue pls help
i need to find percentage using this formula
PERCENTAGE = (@ROD_INCIDENTS/TOTAL_INCIDENTS)*100*100
--([ROD incidents] / [total no of incidents]) x 100 = 0.89 x 100 = 89%
DECLARE @AA AS varchar(10)
SET @AA = convert(varchar(10), CONVERT(decimal(10,7),33/37))
PRINT @AA (result should be 0.07) but i am getting 0.0000000
i need the decimal value so i can perform my percentage
Cheers
October 21, 2009 at 1:17 am
Try this
DECLARE @AA AS varchar(10)
SET @AA = convert(varchar(10), CONVERT(decimal(10,7),33.0000000/37.00000000))
PRINT @AA
October 21, 2009 at 2:52 am
isnt this enough?
DECLARE @AA AS varchar(10)
SET @AA = convert(varchar(10), 33/37.0)
select @AA
as both numbers are integers the output also would be integer. so either one number can be converted to decimal using convert (one last bracket should close after 33)
or multiplied with a decimal (for eg 1.0) and then devided
To restrict the deciamls also you can use convert to decimal
October 28, 2009 at 11:17 am
Hey everyone,
This topic seems to be the closest to what I'm looking for. I've got a calculation that needs to return a decimal, however, I get the same error of just returning 0.000000. What am I missing? Using the previous example:
declare @mpr as decimal(8,8)
set @mpr = convert(decimal(8,8), 90/407)
select @mpr
October 28, 2009 at 1:27 pm
Ok, got this. Each variable has to be converted.
convert(decimal, Variable)/convert(decimal, (DateDiff("d",DateVar,DateVar)))
October 29, 2009 at 1:01 am
This can do
declare @mpr as decimal(8,8)
set @mpr = convert(decimal(8,8), 90*1.0/407)
select @mpr
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply