× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Darren,

the following example should return the correct result without explicitly
converting the numeric values:

select iclead / (5 / 7.00)*2
from CIC

The rule is: If two (or more) integer values are combined in a calculation
the result will be an integer again.
Even though iclead is a decimal value, because 5/7 is embedded in
parenthesis, 5/7 is calculated separately and since these are both integers
(no decimal positions) the result will be an integer again.
5/7 results in something like 0.714285... but since there is no rounding the
result is truncated to 0.

If you add a decimal point and at least one decimal positions. The numbers
are no longer interpreted as inter values, but as decimal values and in this
way the result will be calculated correctly.

Do you really need the parenthesis?
Select ICLEAD / 5 * 7 * 2
From CIC
Should return the correct result.

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
?Train people well enough so they can leave, treat them well enough so they
don't want to.? (Richard Branson)


-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of
Darren Strong
Sent: Donnerstag, 2. November 2017 20:49
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Subject: Re: SQL result data types

Thank you Rob. That was it. And a special thank you to SQL for figuring that
5/7 was zero.


___________________________________
Darren Strong
Dekko





From: Rob Berendt <rob@xxxxxxxxx>
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Date: 11/02/2017 03:44 PM
Subject: Re: SQL result data types
Sent by: "MIDRANGE-L" <midrange-l-bounces@xxxxxxxxxxxx>



There has to be a prettier way but this is effective
values (dec(5, 15, 5) / dec(7, 15, 5)) * 2


Rob Berendt

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.