Solved

Retaining floating point values in Sybase

Posted on 2012-03-27
4
871 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 83

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 250 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 250 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

734 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