shole
shole

Reputation: 4094

T-SQL select row if one specific column's decimal part is not 0

I have a table with one of the columns : cost, it is of decimal type with 2 d.p.

Now I would like to select all rows from this table where cost's decimal part is not 0

For example, I do not select the row if cost is 150.00 or 222.00, but would like to select if cost is 0.20 or 123.12, etc.

How can this be done in a single select query?

Upvotes: 3

Views: 322

Answers (2)

artm
artm

Reputation: 8584

select *
from table1
WHERE
convert(decimal(10,0), cost) <> cost

Upvotes: 1

Martin Smith
Martin Smith

Reputation: 453707

For rows where there is a zero decimal part Floor(cost) will equal cost and it won't where there is a non zero decimal part.

SELECT *
FROM YourTable
WHERE Floor(cost) <> cost;

Upvotes: 5

Related Questions