type

DECIMAL

Exact decimal arithmetic is useful for prices. In PostgreSQL precision counts significant digits and scale controls fractional rounding in ordinary nonnegative-scale declarations. Example target: PostgreSQL 17. Run in a disposable database; examples need no existing tables.

Formal Syntax & Structure

sql syntaxsql
DECIMAL(p,s)

Working Example

Example Snippetsql
SELECT CAST(CAST(12.345 AS DECIMAL(5,2)) AS TEXT);
SQL Reference