Solved

How can I get [select 27/30] to return .09 instead of 0?

Posted on 2008-10-17
3
164 Views
Last Modified: 2010-03-19
In SQL Server (version 2005 if it even matters), how do I get this division to return the value of .9 instead of 0?

SELECT 27/30

I tried casting and converting to decimal/numeric to no avail.
0
Comment
Question by:reallyv
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
Marcjev earned 125 total points
ID: 22742197
do
select 27.0 / 30

or

select convert(float,27)/30

so make the type not int...
0
 
LVL 10

Expert Comment

by:Marcjev
ID: 22742209
if you only convert the result, the int division has already taken place and you actually convert the zero...
0
 

Author Comment

by:reallyv
ID: 22742758
Thank you thank you!
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question