diff --git a/4.sql b/4.sql index e69de29..8a9ecab 100644 --- a/4.sql +++ b/4.sql @@ -0,0 +1,12 @@ +-- write a SQL query to find the 50 players paid the least in 2001. +-- Sort players by salary, lowest to highest. +-- If two players have the same salary, sort alphabetically by first name and then by last name. +-- If two players have the same first and last name, sort by player ID. +-- Your query should return three columns, one for players’ first names, one for their last names, and one for their salaries. +SELECT + p."first_name", p."last_name", s."salary" +FROM "players" as p +JOIN "salaries" as s + ON s."player_id" = p."id" +ORDER BY s."salary" ASC, p."first_name" ASC, p."last_name" ASC, p."id" ASC +LIMIT 50;