bot50
2026-04-28 14:42:24 +00:00
commit 144001e997
12 changed files with 153 additions and 0 deletions

26
10.sql Normal file
View File

@@ -0,0 +1,26 @@
-- To be precise, the table should include:
-- All players first names
-- All players last names
-- All players salaries
-- All players home runs
-- The year in which the player was paid that salary and hit those home runs
-- In 10.sql, write a query to return just such a table.
-- Your query should return a table with five columns, per the above.
-- Order the results, first and foremost, by players IDs (least to greatest).
-- Order rows about the same player by year, in descending order.
-- Consider a corner case: suppose a player has multiple salaries or performances for a given year.
-- Order them first by number of home runs, in descending order, followed by salary, in descending order.
-- Be careful to ensure that, for a single row, the salarys year and the performances year match.
SELECT p."first_name", p."last_name", s."salary", perf."HR", s."year"
FROM "players" AS p
JOIN "salaries" AS s
ON s."player_id" = p."id"
JOIN "performances" AS perf
ON perf."player_id" = p."id"
AND perf."year" = s."year"
ORDER BY
p."id" ASC,
s."year" DESC,
perf."HR" DESC,
s."salary" DESC;