Solved

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

Posted on 2008-10-17
3
166 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

717 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