Classic SQL Interview Queries

This SQL quiz walks through the classic interview queries and the traps hidden in each one. You will work out second highest and Nth highest salaries, find and delete duplicates, rank rows per group and compare employees with their managers.

ยาก 10 ข้อ ~8 นาที ผ่านที่ 80% SQLite

เลือกโหมด

กำลังเล่นแบบผู้เยี่ยมชม: เข้าสู่ระบบเพื่อเก็บ XP และ streak

ตัวอย่างคำถาม

ข้อ 1 จาก 10

What does this print?

CREATE TABLE employees (id INTEGER, name TEXT, salary INTEGER);
INSERT INTO employees VALUES
  (1, 'Ann', 9000), (2, 'Bob', 9000), (3, 'Cy', 7000), (4, 'Dee', 5000);
SELECT MAX(salary) FROM employees
WHERE salary < (SELECT MAX(salary) FROM employees);
ดูเฉลย

B. 7000 The subquery finds the top salary (9000), and the outer query takes the largest salary below it. Ties at the top do not matter, so this returns the second highest distinct salary, 7000.

ควิซนี้มีเนื้อหาอะไรบ้าง

  • Second and Nth highest salary, with ties
  • Finding and deleting duplicate rows
  • Top N per group with window functions
  • Self joins, like employees earning more than their manager
  • Rows with no match (anti-joins)

คำถามที่พบบ่อย

ต้องมีบัญชีไหม?

ไม่ต้อง ใครก็เล่นได้ เข้าสู่ระบบเพื่อเก็บ XP, streak, เหรียญตรา และประวัติ

ทำซ้ำได้ไหม?

ได้ ระบบเก็บคะแนนที่ดีที่สุดไว้ และสลับคำถามกับตัวเลือกใหม่ทุกครั้ง