SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Filtering data using float column


Filtering data using float column

Author
Message
stanley 86917
stanley 86917
Grasshopper
Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)

Group: General Forum Members
Points: 16 Visits: 11
how to filter the negative value from the float column
LutzM
LutzM
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10267 Visits: 13559
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
stanley 86917
stanley 86917
Grasshopper
Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)

Group: General Forum Members
Points: 16 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
LutzM
LutzM
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10267 Visits: 13559
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
stanley 86917
stanley 86917
Grasshopper
Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)Grasshopper (16 reputation)

Group: General Forum Members
Points: 16 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...
LutzM
LutzM
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10267 Visits: 13559
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search