Query for decimal part

Ask a Question related to Informix, Design and Development.

  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. Similar Questions and Discussions

    1. #39906 [NEW]: Unable to use place holders as part of the actual SQL query with PDO's
      From: iab398 at bham dot ac dot uk Operating system: Unix PHP version: 5.2.0 PHP Bug Type: SQLite related Bug description: ...
    2. Query problem part 2
      You are getting the correct data. In your output, you should either do nested <cfoutputs> or a <cfloop> nested in an output. In either case, your...
    3. Using a & in a query that is actually part of a name
      How do I use a & in a query without the script treating it a a concatenation character? For example, I have a company name in a field called "M &...
    4. decimal validation
      how can i use javascript to ensure a the user enters a decimal number up to a certain place holder? what would that code look like? Chris O'Brien
    5. Need to get the decimal part of a number
      Hi. How can I -from an ASP page- get the decimal part of a number ? Thanks in advance for all your help.
  3. #2

    Default Re: Query for decimal part

    On Thu, 21 Aug 2003 10:32:29 -0600, Francisco Roldan
    <froldan@5b.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

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

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

  6. #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.dhaliwal@dhl.com]
    Enviado el: Jueves, 21 de Agosto de 2003 11:29 a.m.
    Para: Francisco Roldan
    CC: [email]informix-list@iiug.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

  7. #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" <froldan@5b.com.gt>
    To: <informix-list@iiug.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

Posting Permissions

  • You may not post new threads
  • You may 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