🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: SQL Interview Queries: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. Which query finds duplicate emails in a users table?
  2. Q2. After departments LEFT JOIN employees, which gives 0 (not 1) for a department with no employees?
  3. Q3. Salaries are 90, 80, 80, 70. What is the second highest DISTINCT salary?
  4. Q4. Why write 100.0 SUM(x) / total instead of 100 SUM(x) / total?
  5. Q5. "Highest salary in each department with the employee name" — what must you mention?
  6. Q6. Which query gives the 3rd highest distinct salary using LIMIT and OFFSET?
  7. Q7. To delete duplicate emails but keep the first sign-up of each, which rows are kept?
  8. Q8. In the company table, how many people report directly to Asha?
  9. Q9. Which query lists employees who have no manager?
  10. Q10. Why is joined = '2022-01-01' AND joined < '2024-01-01' preferred over YEAR(joined) IN (2022, 2023)?