Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2006
    Posts
    5

    Unanswered: Selecting only integer values from a field

    I have a field that has integer and non-integer data. For just this one query, I need to select out only the integer values. How do I make a query ingore any value that has a decimal attached? (I don't need to round... I only want to select the whole numbers.)

    Thanks in advance for any help you can provide!
    Cathy

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Talking


    Try:
    Code:
    Select * From MyTable
      Where The_Number = TRUNC(The_Number);

    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  3. #3
    Join Date
    Dec 2003
    Posts
    1,074
    I think TRUNC with no arguments should do the trick

    Code:
    drop table t;
    
    create table t (f number(4,2));
    
    insert into t values (12.57);
    insert into t values (15);
    insert into t values (3.8);
    
    select trunc(f) from t;
    
      TRUNC(F)
    ----------
            12
            15
             3
    
    3 rows selected.
    -cf

  4. #4
    Join Date
    Sep 2006
    Posts
    5

    Reply

    Trunc is still giving me the values that have decimals. I need to completely ignore the values that have decimals and only report out the whole number values.

    So, in your example, the only result I would want to product is 15. The other two values should not be part of my result set.

    Any other ideas?

  5. #5
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Select Val1
    From Mytable
    Where Trunc(val1) = Val1;
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  6. #6
    Join Date
    Sep 2006
    Posts
    5

    Reply

    Sorry! You are right. It works perfectly!

    Cathy

Posting Permissions

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