PGoCareerGoCareer prep tools
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

SQL · Theory

DECIMAL

← All stacks

Theory

301/439

DECIMAL

DECIMAL(10,2) is exact: 10 digits, 2 after the point — money, percentages you must not round wrongly. FLOAT/DOUBLE are approximate binary. Banks and fees: DECIMAL.

10,2 means 8 digits before the point + 2 after (total 10). Don’t guess — say ‘precision and scale’.

Trap — FLOAT for salary.

On the example next to this theory: DECIMAL: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

Exam tip

fee DECIMAL(10,2) NOT NULL

DECIMAL — sample query

-- DECIMAL
CREATE TABLE demo (
  id INTEGER PRIMARY KEY,
  label TEXT NOT NULL,
  qty INTEGER DEFAULT 0
);
INSERT INTO demo (id, label, qty) VALUES
  (1, 'alpha', 2),
  (2, 'beta', 5);
SELECT label, qty FROM demo WHERE qty >= 2 ORDER BY qty DESC;

DECIMAL: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

Short notes

  • DefDECIMAL(p,s) exact number. Money uses this.
  • RuleNot FLOAT for currency.
  • TrapFLOAT salary.

Questions

1

Why DECIMAL for money?

301 / 439

P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.