From 92f9132939e6c0d44c5713092335a72a595a15bd Mon Sep 17 00:00:00 2001 From: daviddoji Date: Tue, 28 Apr 2026 15:40:19 +0200 Subject: [PATCH] automated commit by check50 [check50=True] --- 3.sql | 2 +- 4.sql | 4 ++-- 5.sql | 6 +++--- 6.sql | 11 +++++++++++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/3.sql b/3.sql index b84b33e..52d4460 100644 --- a/3.sql +++ b/3.sql @@ -3,7 +3,7 @@ -- Note that there may be two players with the name “Ken Griffey.” This Ken Griffey was born in 1969. -- Your query should return a table with two columns, one for year and one for home runs. SELECT perf."year", perf."hr" -FROM "performances" as perf +FROM "performances" AS perf JOIN "players" AS p ON perf."player_id" = p."id" WHERE diff --git a/4.sql b/4.sql index ad7e69e..9ea8b9c 100644 --- a/4.sql +++ b/4.sql @@ -5,8 +5,8 @@ -- 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 +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 diff --git a/5.sql b/5.sql index 3cfb73d..6ad97a4 100644 --- a/5.sql +++ b/5.sql @@ -1,9 +1,9 @@ -- write a SQL query to find all teams that Satchel Paige played for. -- Your query should return a table with a single column, one for the name of the teams. SELECT DISTINCT t."name" -FROM "teams" as t -JOIN "performances" as perf +FROM "teams" AS t +JOIN "performances" AS perf ON perf."team_id" = t."id" -JOIN "players" as p +JOIN "players" AS p ON p."id" = perf."player_id" WHERE p."first_name" = "Satchel" AND p."last_name" = "Paige"; diff --git a/6.sql b/6.sql index e69de29..1f42545 100644 --- a/6.sql +++ b/6.sql @@ -0,0 +1,11 @@ +-- write a SQL query to return the top 5 teams, sorted by the total number of hits by players in 2001. +-- Call the column representing total hits by players in 2001 “total hits”. +-- Sort by total hits, highest to lowest. +-- Your query should return two columns, one for the teams’ names and one for their total hits in 2001. +SELECT t."name", perf."H" AS "total hits" +FROM "teams" AS t +JOIN "performances" AS perf + ON perf."team_id" = t."id" +WHERE perf."year" = "2001" +ORDER BY "total hits" DESC +LIMIT 5;