Files
me50/4.sql
2026-04-28 15:21:39 +02:00

14 lines
661 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- 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"
WHERE s."year" = "2001"
ORDER BY s."salary" ASC, p."first_name" ASC, p."last_name" ASC, p."id" ASC
LIMIT 50;