sql - PostgreSQL : How to select values with only two digits after decimal point in a table? -


i have table called nums.

create table nums (num numeric); insert  nums select * (values(10.11),(11.122),(12.22),(13.555)) t; 

it have following rows

select * nums  num -------- 10.11 11.122 12.22 13.555 

so question how values 2 digits after decimal point(.)?


expected output :-

    num     --------     10.11     12.22 

you can try pattern matching

select * nums num::text ~ '(^\d+(\.\d{1,2})?$)'; 

or mathematical functions , operators - floor

select * nums floor (num*100)=num*100 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -