?
Solved

Retaining floating point values in Sybase

Posted on 2012-03-27
4
Medium Priority
?
876 Views
Last Modified: 2012-06-27
Hi Experts...
I have a calculation to be done in a query as shown below:
 ((28154/3745181) * 100) whose resultant vaalue is .751739 which i want it as 0.75
But when i try to do in a query i get 0 as shown below.

select  ((28154/3745181) * 100) --Returns 0 as the result.
How can i get the desired 0.75 as the resultant.
Please help...
0
Comment
Question by:gaugeta
[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
4 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 37770480
0
 

Author Comment

by:gaugeta
ID: 37770488
@DaveBaldwin:Thanks for the reply.
I still get 0.00 as the result.
Please help...
0
 
LVL 14

Assisted Solution

by:Jan Franek
Jan Franek earned 1000 total points
ID: 37771725
Sybase automaticaly converts result to the same datatype as the parameters. So 28154/3745181 will result in 0 (result truncated).

So you need to convert one of parameters to float or other similar type:

select convert(float,28154)/3745181 will give you 0.0075173936853786235

Then you can use round function to get desired result:

select round(  ((convert(float,28154)/3745181) * 100) , 2 )
0
 
LVL 13

Accepted Solution

by:
alpmoon earned 1000 total points
ID: 37773679
What are the actual datatypes? You can get the actual value by just adding '.0' without conversion if you are using constants:

select round( ( (28154/3745181.0) * 100) , 2 )
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
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…

752 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