Top 5 Highest Paid Interns
UptoSkills Arena is helping a startup recruit interns. They need a list of the 5 highest-paid interns to consider for full-time roles.
Tables:
interns:intern_id(integer),name(varchar(50)),stipend(numeric(10,2))
Return the name and stipend of the 5 interns with the highest stipend, ordered by stipend in descending order. If there are ties in stipend, the order among tied interns does not matter. NULL stipends should not be considered. If fewer than 5 interns exist, return all of them.
Tables
CREATE TABLE interns ( intern_id integer PRIMARY KEY, name varchar(50) NOT NULL, stipend numeric(10,2) );
Example data
INSERT INTO interns (intern_id, name, stipend) VALUES (1, 'Alice', 5000.00), (2, 'Bob', 4500.00), (3, 'Charlie', 5000.00), (4, 'David', 6000.00), (5, 'Eve', 4800.00), (6, 'Frank', 5500.00), (7, 'Grace', 4500.00);
Your query is also checked on hidden datasets with different data.
Hints
-- Select the names and stipends of the highest-paid interns
SELECT name, stipend
FROM interns
Your query runs on the example tables shown with the problem, then on hidden datasets when you submit.
Write standard SQL. MySQL habits work too: IFNULL, IF, YEAR(), DATE_FORMAT, GROUP_CONCAT, `backticks` and LIMIT 5, 10. It runs on PostgreSQL, so integer division keeps whole numbers (5 / 2 = 2): write 5.0 / 2 for 2.5.