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
| Type | Holds | Use for |
|---|---|---|
| `INTEGER` | whole numbers | counts, IDs, ages |
| `DECIMAL(10,2)` | exact decimals, 2 places here | money — spend in our examples |
| `REAL` / `DOUBLE PRECISION` | approximate decimals | scientific 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
marketingPrefix tables with marketing.table_name.
namespendbuffered_spendmarketing.campaigns| Column | Type |
|---|---|
| id | integer |
| name | text |
| channel | text |
| spend | numeric |
| start_date | date |
| end_date | date |
| status | text |
| target_segment | text |
| legacy_id | text |
query.sql
Sign up free to try it on a real business scenario