January 20, 2010 at 11:55 pm
I am looking of simple division result
declare @overallavailablity decimal (18,4)
select @overallavailablity = 676/10080
print @overallavailablity
expecting result to come as 0.0670 but gettting 0.0000 , could any body pls confirm what i am missing?
I am using sql 2008.
Thanks!!
January 21, 2010 at 12:28 am
try this!!!
declare @overallavailablity decimal (18,4)
declare @numerator decimal (18,4)
declare @denominator decimal (18,4)
sET @numerator = 676
SET @denominator = 10080
select @overallavailablity = @numerator/@denominator
print @overallavailablity
Regards,
Raj
January 21, 2010 at 12:28 am
Hi,
You’re divided the Integer values, so you get the integer value of the zero (int are the round values, not the decimal)
You convert the int value to decimals then divide the decimal value.
select 676/10080
select cast(676 as decimal (18,4))/cast(10080 as decimal (18,4))
January 21, 2010 at 12:29 am
or simply
declare @overallavailablity decimal (18,4)
select @overallavailablity = 676.0000/10080.0000
print @overallavailablity
Regards,
Raj
January 21, 2010 at 1:14 am
Great Thanks all!!
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply