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

SQL · Theory

DISTINCT

← All stacks

Theory

41/439

DISTINCT

DISTINCT is a SQL idea you prove with unique cities, not with a slogan.

DISTINCT on the board — SELECT DISTINCT city. Then say what unique cities looks like after.

Without DISTINCT, student list gets messy and unique cities is hard to trust.

Use DISTINCT when unique cities must stay clear. If a simpler SQL step works, use that instead.

DISTINCT miss — DISTINCT instead of fixing a bad JOIN. Fix it before you talk about advanced SQL.

After DISTINCT, Riya should still remember DISTINCT instead of fixing a bad JOIN.

Viva for DISTINCT — what it is → SELECT DISTINCT city → the mistake (DISTINCT instead of fixing a bad JOIN).

Exam tip

For DISTINCT: definition + student list + one failure.

DISTINCT — sample query

CREATE TABLE sales (id INTEGER PRIMARY KEY, region TEXT, amount INTEGER);
INSERT INTO sales VALUES (1, 'N', 100), (2, 'N', 80), (3, 'S', 120);
SELECT region, SUM(amount) AS total
FROM sales
GROUP BY region
HAVING total >= 150
ORDER BY total DESC;

DISTINCT — gROUP BY aggregates; HAVING filters groups; ORDER BY sorts the result.

Short notes

  • DefDISTINCT — Riya uses it for unique cities in student list.
  • RuleDISTINCT → SELECT DISTINCT city.
  • RememberDISTINCT + the query planner (student list).
  • UseDISTINCT in student list (unique cities).
  • TrapDISTINCT — DISTINCT instead of fixing a bad JOIN.
  • ExDISTINCT → unique cities.

Questions

1

Define DISTINCT without jargon. Then point at unique cities.

2

If you skip DISTINCT, what breaks in student list?

3

Which mistake makes unique cities fail?

4

Show DISTINCT in the query planner terms — three lines max.

Previous← WHERENextFROM →
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.