Question

I am trying to create a select statemeny for SQL where I'm trying to view all results where the value is not zero in a field with the decimal type

SELECT * FROM Table1 WHERE Decimalvalue !== '0';

is what I'm trying and it doesn't seem to work for me, Any ideas?

Was it helpful?

Solution 2

Try

SELECT * 
FROM Table1 
WHERE Decimalvalue <> '0';

OTHER TIPS

The correct comparison operator in SQL is <>. And, you shouldn't compare a known number to a string:

WHERE Decimalvalue <> 0;

Some considerations. If you have NULL values, these will also be filtered out, so you might want:

WHERE Decimalvalue <> 0 or DecimalValue is null;

You are using the word "decimal", perhaps without realizing that it has a specific meaning in SQL. "Decimal" refers to a fixed point representation, rather than a floating point representation. With floating point values, you can have results that look exactly the same, but differ at the nth decimal place. In that case, you can do something like:

WHERE abs(Decimalvalue) > 0.0001 or DecimalValue is null;

Or whatever threshold you are comfortable with.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top