How do I count decimal places in SQL?

前端 未结 6 730
日久生厌
日久生厌 2020-12-06 01:30

I have a column X which is full of floats with decimals places ranging from 0 (no decimals) to 6 (maximum). I can count on the fact that there are no floats with greater th

6条回答
  •  长情又很酷
    2020-12-06 02:10

    Solution for Oracle but you got the idea. trunc() removes decimal part in Oracle.

    select *
    from your_table
    where (your_field*1000000 - trunc(your_field*1000000)) <> 0;
    

    The idea of the query: Will there be any decimals left after you multiply by 1 000 000.

提交回复
热议问题