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

SQL · Theory

first()

← All stacks

Theory

124/439

first()

MIN(marks) lowest value, skips NULL. SELECT name, marks FROM students WHERE marks = (SELECT MIN(marks) FROM students); can return several students who tied.

MIN on strings is alphabetical (collation). MIN on dates is earliest.

Trap — MIN as ‘first inserted row’ — it is not, unless you MIN(id).

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

Exam tip

MIN(marks) lowest score. Subquery to get those students.

first() — sample query

-- first()
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;

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

Short notes

  • DefMIN = smallest non-NULL value.
  • RuleTies: several rows can share the min.
  • TrapMIN meaning ‘first row’.

Questions

1

Lowest marks?

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