Vladi
Vladi

Reputation: 244

MSSQL filter results only with more than 2 digits after separator

For example, I have the following result set:

11.2300,
23.4560,
10.4100,
12.5677,

Can someone please write me how to make a filter in MSSQL that will show me only these results:

23.4560,
12.5677

I want to find all the results where the last two digits are not 00.

Thanks!

Upvotes: 1

Views: 38

Answers (2)

Lukasz Szozda
Lukasz Szozda

Reputation: 175756

Using % (remainder/modulo division):

CREATE TABLE #tab(col DECIMAL(10,4));

INSERT INTO #tab(col)
VALUES (11.2300),(23.4560),(10.4100),(12.5677);

SELECT col
FROM  #tab
WHERE  col % 0.01 <> 0;

LiveDemo

Upvotes: 2

Tab Alleman
Tab Alleman

Reputation: 31785

WHERE RIGHT(CAST(MyColumn AS Varchar(31)), 2) <> '00'

Upvotes: 1

Related Questions