Professional Web Applications Themes

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. #1

    Default 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 ?

    Thanks in advance
    sending to informix-list
    Francisco Roldan Guest

  2. #2

    Default 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. #3

    Default Re: Query for decimal part


    Hi,

    Try something like this -

    select * from rep_data where
    (round(adr_cr_limit,0) * 100 - adr_cr_limit * 100) != 0


    ( 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 ?
    >
    >Thanks in advance
    >sending to informix-list
    >
    >
    sending to informix-list
    preetinder dhaliwal Guest

  4. #4

    Default 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 ?
    >
    > Thanks in advance
    > 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. #5

    Default 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
    (round(adr_cr_limit,0) * 100 - adr_cr_limit * 100) != 0


    ( 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 ?
    >
    >Thanks in advance
    >sending to informix-list
    >
    >
    sending to informix-list
    Francisco Roldan Guest

  6. #6

    Default 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 ?
    >
    > Thanks in advance
    > sending to informix-list
    sending to informix-list
    Fernando Ortiz Guest

Similar Threads

  1. Replies: 1
    Last Post: December 20th, 04:42 PM
  2. Query problem part 2
    By tejun in forum Coldfusion Database Access
    Replies: 1
    Last Post: February 21st, 10:40 PM
  3. Using a & in a query that is actually part of a name
    By Phillip Windell in forum ASP Database
    Replies: 19
    Last Post: January 19th, 07:50 AM
  4. decimal to hex and back
    By Andrea Corrado Campitelli in forum Adobe Flash, Flex & Director
    Replies: 4
    Last Post: January 16th, 02:28 PM
  5. Replies: 1
    Last Post: June 30th, 09:59 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139