SQL Numbers

Whole numbers, exact decimals, and approximate decimals are genuinely different types — not just stylistic choices.

What & Why

Postgres separates numeric types by exactness, not just size. INTEGER holds whole numbers only. DECIMAL/NUMERIC holds exact fractional values — no rounding error, ever. REAL/DOUBLE PRECISION are approximate floating-point types, faster but capable of tiny rounding errors.

See How It Works

REFERENCE EXAMPLE
TypeHoldsUse for
`INTEGER`whole numberscounts, IDs, ages
`DECIMAL(10,2)`exact decimals, 2 places heremoney — spend in our examples
`REAL` / `DOUBLE PRECISION`approximate decimalsscientific measurements, never money

The result uses the same Queryflo columns shown in the worked example.

Now You Try

Practice this concept

Marketing wants each campaign spend beside a 10 percent buffered spend estimate.

Available schema
marketing

Prefix tables with marketing.table_name.

namespendbuffered_spend
marketing.campaigns
ColumnType
idinteger
nametext
channeltext
spendnumeric
start_datedate
end_datedate
statustext
target_segmenttext
legacy_idtext
query.sql
Beginner business practice

Sign up free to try it on a real business scenario