Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Query Help

Author  Topic 

mvanwyk
Yak Posting Veteran

99 Posts

Posted - 2009-06-23 : 08:20:06
Hi Guys.

Thanks in advance for any help here.

I can't get my head around this problem.

select 50/60*100 the result = 0 what am i missing here?
i even tried this as well.
select CAST(((50/60)*100) AS Decimal)

But that gives me a 0 as well, i'm trying to work out the percentage here.
The result should be 83.33333333

Thank again.




jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-06-23 : 08:22:19
It's because 50 and 60 are integers and int/int = int. Try (50.0/60)*100.

Jim
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-06-23 : 08:23:41
Or more clear try ((50*1.0)/60)*100

Jim
Go to Top of Page

mvanwyk
Yak Posting Veteran

99 Posts

Posted - 2009-06-23 : 08:27:17
Thanks jimf
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-06-23 : 09:04:09
SELECT @a / @b * 100.0E


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -