Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Transact-SQL Loses decimals on divide

Posted on 2004-08-08
2
Medium Priority
?
1,159 Views
Last Modified: 2008-03-10
Hello,

Why, does 15 / 60 return 0?  For example, in transact-sql, if I execute the query

print 15 / 60

SQL returns 0 instead of 0.25.

I guess it is assuming an Integer datatype for some reason.... how could I fix that?

Thanks!
0
Comment
Question by:quiTech
[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 Comments
 
LVL 15

Accepted Solution

by:
jdlambert1 earned 750 total points
ID: 11749514
You need to make the numerator a decimal:

DECLARE @num1 decimal(10,5)
SET @num1 = 15
SELECT @num1 / 60
0
 

Author Comment

by:quiTech
ID: 11749567
Works great!  Thanks!
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
What we learned in Webroot's webinar on multi-vector protection.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

650 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