PL/SQL : query numeric data type by scale

oracleplsql

Wish to select rows with number fields having a certain amount of data after the decimal

eg

select number from table where number.scale > 4;

Is this possible to do directly, or must I cast to string and parse character wise

Best Answer

If I understand the question correctly you want to find numbers that have, for example, more than 4 digits of precision after the decimal? E.g., you want 3.0671, 3.06713, etc. but not 3.067 or 3.06 or 3. If that is the case then you could do something like:

select number from table where number - trunc(number,4) <> 0;

trunc here will simply remove everything ater the fourth decimal digi

(I'm not taking into consideration what Nick said regarding 2 and 2.00.)