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

x
?
Solved

Retaining floating point values in Sybase

Posted on 2012-03-27
4
Medium Priority
?
885 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

604 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