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
ID: 22742197
select 27.0 / 30


select convert(float,27)/30

so make the type not int...
LVL 10

Expert Comment

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

Author Comment

ID: 22742758
Thank you thank you!

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

803 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