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

SQL · Theory

SELECT Record

← All stacks

Theory

35/439

SELECT Record

SELECT name, marks FROM students WHERE marks < 40 ORDER BY marks; is the whole language in one line. SELECT = which columns. FROM = which table. WHERE = which rows. ORDER BY = sort.

SELECT * is fine at home. In interviews, list columns. DISTINCT removes duplicate rows in the result. LIMIT 10 is ‘first 10’ after sorting.

Functions — SELECT COUNT(*), AVG(marks) FROM students; aggregates. They collapse rows unless you GROUP BY.

Trap: WHERE after GROUP BY (illegal — use HAVING). Trap: SELECT extra columns not in GROUP BY (ONLY_FULL_GROUP_BY error).

On the example next to this theory — SELECT Record — sELECT projects columns; WHERE filters; ORDER BY sorts.

Diagram
FROM students
       │ WHERE marks < 40
       ▼
  matching rows
       │ SELECT name, marks
       ▼
  result table
Exam tip

SELECT name, marks FROM students WHERE marks < 40;

SELECT Record — sample query

CREATE TABLE employees (id INTEGER PRIMARY KEY, name TEXT, dept TEXT, salary INTEGER);
INSERT INTO employees VALUES
  (1, 'Asha', 'Eng', 70000),
  (2, 'Ravi', 'Eng', 65000),
  (3, 'Neha', 'HR', 50000);
SELECT name, salary FROM employees WHERE dept = 'Eng' ORDER BY salary DESC;

SELECT Record — sELECT projects columns; WHERE filters; ORDER BY sorts.

Short notes

  • DefSELECT columns FROM table WHERE rows.
  • RuleFROM → WHERE → SELECT in your head. ORDER BY / LIMIT last.
  • TrapSELECT * as the only habit. WHERE vs HAVING.

Questions

1

Write a SELECT for fail students.

2

What does FROM do?

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