How do I query a field for a few small numbers?
MySQL database:
Through the following SQL can be found out, there are 2 col*100, there are 3 col*1000, one analogy;
Select * from where real_quantity*-Floor (real_quantity*1000 >0
Note: Floor: The function returns only the integer part, and the fractional part is discarded.
Oracle Database:
Select LTrim ('124532.62879'-Floor ('124532.62879'), ' 0.' from dual; Select Length (66695 from dual;
With these two SQL combinations, you can find out the number of decimal places in the back part of the dotted line, classic in Oracle, and practical!
The following approach is also Classic (recommended):
For example, a field with a table is number (10,4), but most of it is 3 decimal places, how to query the results of 4 decimal places:
Select * from where (Col- trunc (col,3<>0 ; Select Length ('21221.3410'- InStr (' 21221.3410','. ' from dual;
Finally, I summarize the following sql:
---query where the decimal point is located
Select InStr ('12563.26530','. ' from dual;
---query decimal parts
Select substr ('12563.26530', InStr ('12563.26530', ' . ') + 1 from dual;
---Query the length of a fractional part
Select Length (substr ('12563.26530', InStr ('12563.26530 ','. ') + 1 from dual;
MySQL queries the number of decimal places