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
 Simple Percentage Conversion

Author  Topic 

funk.phenomena
Posting Yak Master

121 Posts

Posted - 2012-03-26 : 17:11:48
Hi All - I have a VERY simple SELECT statement that involves a percentage calculation.


SELECT ((1+1+1+0)/4)
SELECT STR (((1+1+1+0)/4)*100,12,2)


I would like the following statement to output '0.75', but instead it keeps outputting '0.00'.

Any ideas?

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2012-03-26 : 17:20:27
SELECT STR (((1+1+1+0)/4.0),12,2)
Go to Top of Page

funk.phenomena
Posting Yak Master

121 Posts

Posted - 2012-03-26 : 17:30:58
Works!
Didn't realize I had to have the denominator formatted as decimal.
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2012-03-26 : 17:32:43


yep, else it assumes integers and returns the floor.
Go to Top of Page
   

- Advertisement -