SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Simple Percentage Conversion
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

funk.phenomena
Posting Yak Master

Canada
120 Posts

Posted - 03/26/2012 :  17:11:48  Show Profile  Reply with Quote
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?

Edited by - funk.phenomena on 03/26/2012 17:13:13

russell
Pyro-ma-ni-yak

USA
5072 Posts

Posted - 03/26/2012 :  17:20:27  Show Profile  Visit russell's Homepage  Reply with Quote
SELECT STR (((1+1+1+0)/4.0),12,2)
Go to Top of Page

funk.phenomena
Posting Yak Master

Canada
120 Posts

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

russell
Pyro-ma-ni-yak

USA
5072 Posts

Posted - 03/26/2012 :  17:32:43  Show Profile  Visit russell's Homepage  Reply with Quote


yep, else it assumes integers and returns the floor.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000