Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumSQLself-joinsSingle-choice MCQ

This self-join is meant to list, per employee, how many peers earn strictly less. Given the data, what is the count for the lowest-paid employee?

-- emp(id, salary): (1,100),(2,200),(3,300) SELECT a.id, COUNT(b.id) AS lower_count FROM emp a LEFT JOIN emp b ON b.salary < a.salary GROUP BY a.id;