Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine postgres numeric max min values

Tags:

postgresql

In one of my PostgreSQL table there is an attribute result with datatype Numeric(20,10).

One of its input value can be +/- infinity.

I want to know with the length (20,10) what are the maximum & minimum values.

like image 991
reiley Avatar asked Oct 16 '14 05:10

reiley


People also ask

How do I find the minimum value of a column PostgreSQL?

PostgreSQL MIN () function an aggregate function that returns the minimum value in a set of values. To find the minimum value in a column of a table, you pass the name of the column to the MIN () function. The data type of the column can be number, string, or any comparable type. SELECT MIN (expression) FROM table_expression ...;

What is the PostgreSQL min function?

The PostgreSQL MIN function is one of them which is used to return the minimum value from the set of record values. We can use the PostgreSQL MIN function for finding the minimum value for the specific column within the table.

What is max function in PostgreSQL?

PostgreSQL max function will take value from a single as well as multiple columns to form valid mathematical expression from this expression max function will return the maximum values from the column.

How does PostgreSQL treat NaN values?

In order to allow numeric values to be sorted and used in tree-based indexes, PostgreSQL treats NaN values as equal, and greater than all non- NaN values. The types decimal and numeric are equivalent. Both types are part of the SQL standard. 8.1.3.


1 Answers

For a numeric of numeric(precision, scale), the limit values are:

+- ((10^precision)-1)/(10^scale)

so for numeric(20,10) that'd be ((10^20)-1)/(10^10) or 9999999999.9999999999 .

Details in the manual.

like image 159
Craig Ringer Avatar answered Sep 21 '22 21:09

Craig Ringer