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

Posted on 2008-10-17
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.
Question by:reallyv
  • 2
LVL 10

Accepted Solution

Marcjev earned 125 total points
Comment Utility
select 27.0 / 30


select convert(float,27)/30

so make the type not int...
LVL 10

Expert Comment

Comment Utility
if you only convert the result, the int division has already taken place and you actually convert the zero...

Author Comment

Comment Utility
Thank you thank you!

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now