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

SQL · Theory

max()

← All stacks

Theory

122/439

max()

MAX(marks) highest value. Topper query: ORDER BY marks DESC LIMIT 1 or WHERE marks = (SELECT MAX(marks) FROM students). The subquery form keeps ties.

LIMIT 1 hides ties. Say that in the interview.

Trap — MAX without mentioning ties.

On the example next to this theory — max() — aggregate functions collapse many rows into one summary row.

Exam tip

MAX(marks). Ties: WHERE marks = (SELECT MAX(marks) FROM students).

max() — sample query

CREATE TABLE scores (id INTEGER PRIMARY KEY, marks INTEGER);
INSERT INTO scores VALUES (1, 80), (2, 90), (3, 70);
SELECT COUNT(*) AS n, AVG(marks) AS avg_marks, MAX(marks) AS top
FROM scores;

max() — aggregate functions collapse many rows into one summary row.

Short notes

  • DefMAX = largest non-NULL value.
  • RuleSubquery keeps ties. LIMIT 1 may hide them.
  • TrapAssuming one unique topper.

Questions

1

All toppers, not one?

122 / 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.