April 27, 2010 at 11:25 pm
how to filter the negative value from the float column
April 28, 2010 at 3:43 am
Maybe something like this?
WHERE float_column > = 0.0
April 28, 2010 at 4:28 am
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
April 28, 2010 at 12:23 pm
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?
April 28, 2010 at 9:52 pm
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...
April 29, 2010 at 9:22 am
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
*/
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy