Filtering data using float column

  • how to filter the negative value from the float column

  • Maybe something like this?

    WHERE float_column > = 0.0



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • Hi,

    Na. I tried and it wont work. It will bring the negative values too.

    i checked with case and its working in select clause but not in where clause. thats the problem

  • Here's a sample code that works as expected:

    DECLARE @tbl TABLE ( float_column FLOAT )

    INSERT INTO @tbl

    SELECT 0 UNION ALL

    SELECT 0.001 UNION ALL

    SELECT -0.001 UNION ALL

    SELECT -1110

    SELECT *

    FROM @tbl

    WHERE float_column > = 0.0

    /* result set

    float_column

    0

    0,001

    */

    What values would I need to insert to describe the scenario you're faced with?



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

  • Hi,

    Create table ab

    (

    date datetime,

    amount decimal(10,2),

    interest float,

    )

    data:

    2009-04-10 00:00:00.000 450.00 00.23

    2009-04-10 00:00:00.000 451.00 -1.20

    2009-04-10 00:00:00.000 460.00 2.5

    select date, amount, interest from ab where interest > 0

    Output:

    Its showing the all the record. but i need only two records.

    also i tried below query, but not

    select date, amount, interest

    from ab

    where case sign(amount) when -1 then 1 else 0 end = 0

    Thanks...

  • Still not sure what the problem is... your example works just fine:

    DECLARE @tbl TABLE

    (

    DATE DATETIME,

    amount DECIMAL(10,2),

    interest FLOAT

    )

    INSERT INTO @tbl

    SELECT '2009-04-10 00:00:00.000', 450.00, 00.23 UNION ALL

    SELECT '2009-04-10 00:00:00.000', 451.00, -1.20 UNION ALL

    SELECT '2009-04-10 00:00:00.000', 460.00, 2.5

    SELECT DATE, amount, interest FROM @tbl WHERE interest > 0

    /* result set

    dateamountinterest

    2009-04-10 00:00:00.000450.000,23

    2009-04-10 00:00:00.000460.002,5

    */



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply