# Query for decimal part - Informix

Hi Everybody, I got a table with a column named amount of type decimal(26,8) . I need to make a query to select the rows with no-integers values on this column (amount). I mean the rows with decimal part on its value. Something like this : select * from shclog where get_decimals(amount) <> 0 Assuming that the function get_decimals return the decimal part of the column amount. Does exist a function like this ? Thanks in advance sending to informix-list...

1. ## Query for decimal part

Hi Everybody,
I got a table with a column named amount
of type decimal(26,8) .
I need to make a query to select the rows
with no-integers values on this column (amount).
I mean the rows with decimal part on its value.

Something like this :

select * from shclog
where get_decimals(amount) <> 0

Assuming that the function get_decimals return the
decimal part of the column amount.

Does exist a function like this ?

sending to informix-list
Francisco Roldan Guest 2. ## Re: Query for decimal part

On Thu, 21 Aug 2003 10:32:29 -0600, Francisco Roldan
<froldan5b.com.gt> wrote:
>
>Hi Everybody,
>I got a table with a column named amount
>of type decimal(26,8) .
>I need to make a query to select the rows
>with no-integers values on this column (amount).
>I mean the rows with decimal part on its value.
>
>Something like this :
>
>select * from shclog
>where get_decimals(amount) <> 0
>
>Assuming that the function get_decimals return the
>decimal part of the column amount.
>
>Does exist a function like this ?
>
Well, not exactly, but this may do . . . . the trunc() frunction.

e.g.
select * from shclog
where (amount-trunc(amount)) = 0

amount is 57.95
trunc(amount) would be 57
difference would be 0.25

amount is 34.00
trunc(amount would be 34
difference would be 0
John Carlson Guest 3. ## Re: Query for decimal part

Hi,

Try something like this -

select * from rep_data where

( 100 because my col is decimal 2 )

Rgds
Preetinder

Francisco Roldan wrote:
>Hi Everybody,
>I got a table with a column named amount
>of type decimal(26,8) .
>I need to make a query to select the rows
>with no-integers values on this column (amount).
>I mean the rows with decimal part on its value.
>
>Something like this :
>
>select * from shclog
>where get_decimals(amount) <> 0
>
>Assuming that the function get_decimals return the
>decimal part of the column amount.
>
>Does exist a function like this ?
>
>sending to informix-list
>
>
sending to informix-list
preetinder dhaliwal Guest 4. ## Re: Query for decimal part

I haven't tried it but

select *
from table
where decimal_col != decimal_col::INT

should work

Francisco Roldan wrote:
>
> Hi Everybody,
> I got a table with a column named amount
> of type decimal(26,8) .
> I need to make a query to select the rows
> with no-integers values on this column (amount).
> I mean the rows with decimal part on its value.
>
> Something like this :
>
> select * from shclog
> where get_decimals(amount) <> 0
>
> Assuming that the function get_decimals return the
> decimal part of the column amount.
>
> Does exist a function like this ?
>
> sending to informix-list
--
Paul Watson #
Oninit Ltd # Growing old is mandatory
Tel: +44 1436 672201 # Growing up is optional
Fax: +44 1436 678693 #
Mob: +44 7818 003457 #
[url]www.oninit.com[/url] #
Paul Watson Guest 5. ## RE: Query for decimal part

Thanks John and Preetinder,

It worked both ways :

Select * from table
where (amount-trunc(amount)) <> 0

Select * from table
Where (round(amount,0)*100 - amount * 100)!=0

Both generated the same results.

Thank you very much !!

-----Mensaje original-----
De: preetinder dhaliwal [mailto:preetinder.dhaliwaldhl.com]
Enviado el: Jueves, 21 de Agosto de 2003 11:29 a.m.
Para: Francisco Roldan
CC: [email]informix-listiiug.org[/email]
Asunto: Re: Query for decimal part

Hi,

Try something like this -

select * from rep_data where

( 100 because my col is decimal 2 )

Rgds
Preetinder

Francisco Roldan wrote:
>Hi Everybody,
>I got a table with a column named amount
>of type decimal(26,8) .
>I need to make a query to select the rows
>with no-integers values on this column (amount).
>I mean the rows with decimal part on its value.
>
>Something like this :
>
>select * from shclog
>where get_decimals(amount) <> 0
>
>Assuming that the function get_decimals return the
>decimal part of the column amount.
>
>Does exist a function like this ?
>
>sending to informix-list
>
>
sending to informix-list
Francisco Roldan Guest 6. ## Re: Query for decimal part

Hi Paco:

Try with

select * from shclog
where (amount - amount::int) > 0

HTH

----- Original Message -----
From: "Francisco Roldan" <froldan5b.com.gt>
To: <informix-listiiug.org>
Sent: Thursday, August 21, 2003 11:32 AM
Subject: Query for decimal part

> Hi Everybody,
> I got a table with a column named amount
> of type decimal(26,8) .
> I need to make a query to select the rows
> with no-integers values on this column (amount).
> I mean the rows with decimal part on its value.
>
> Something like this :
>
> select * from shclog
> where get_decimals(amount) <> 0
>
> Assuming that the function get_decimals return the
> decimal part of the column amount.
>
> Does exist a function like this ?
> 