Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Filtering data using float column Expand / Collapse
Author
Message
Posted Tuesday, April 27, 2010 11:25 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, February 24, 2012 3:45 AM
Points: 10, Visits: 11
how to filter the negative value from the float column
Post #911625
Posted Wednesday, April 28, 2010 3:43 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 3:04 PM
Points: 7,125, Visits: 13,175
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
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Post #911738
Posted Wednesday, April 28, 2010 4:28 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, February 24, 2012 3:45 AM
Points: 10, Visits: 11
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


Post #911761
Posted Wednesday, April 28, 2010 12:23 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 3:04 PM
Points: 7,125, Visits: 13,175
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
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Post #912278
Posted Wednesday, April 28, 2010 9:52 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, February 24, 2012 3:45 AM
Points: 10, Visits: 11
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...




Post #912509
Posted Thursday, April 29, 2010 9:22 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 3:04 PM
Points: 7,125, Visits: 13,175
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
date amount interest
2009-04-10 00:00:00.000 450.00 0,23
2009-04-10 00:00:00.000 460.00 2,5
*/





Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Post #912975
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse