Skip to content
CodeKruPro

What does DISTINCT apply to with two columns?

QuizEasy-Medium

The employees table has 10 rows. In department 1, two people earn 95,000. In department 2, two people earn 64,000. Every other pair of department and salary is different. How many rows does this query return?

SELECT DISTINCT dept_id, salary FROM employees;
  • 8: each different pair of dept_id and salary appears once
  • 5: one row per department
  • 10: DISTINCT applies only to dept_id, so salary rows stay
  • An error: DISTINCT accepts only one column

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in