From 9b7ac9c01b7baff5e34bf7da2a9532a5a4f0a273 Mon Sep 17 00:00:00 2001 From: bot50 Date: Wed, 15 Apr 2026 08:41:48 +0000 Subject: [PATCH] daviddoji-cs50/problems/2024/sql/players@20260415T084148.074065866Z --- 1.sql | 2 ++ 10.sql | 0 2.sql | 2 ++ 3.sql | 2 ++ 4.sql | 3 +++ 5.sql | 3 +++ 6.sql | 3 +++ 7.sql | 2 ++ 8.sql | 0 9.sql | 0 10 files changed, 17 insertions(+) create mode 100644 1.sql create mode 100644 10.sql create mode 100644 2.sql create mode 100644 3.sql create mode 100644 4.sql create mode 100644 5.sql create mode 100644 6.sql create mode 100644 7.sql create mode 100644 8.sql create mode 100644 9.sql diff --git a/1.sql b/1.sql new file mode 100644 index 0000000..c759e40 --- /dev/null +++ b/1.sql @@ -0,0 +1,2 @@ +-- write a SQL query to find the hometown (including city, state, and country) of Jackie Robinson. +SELECT "birth_city", "birth_state", "birth_country" FROM "players" WHERE "first_name" = "Jackie" AND "last_name" = "Robinson"; diff --git a/10.sql b/10.sql new file mode 100644 index 0000000..e69de29 diff --git a/2.sql b/2.sql new file mode 100644 index 0000000..edfd0b7 --- /dev/null +++ b/2.sql @@ -0,0 +1,2 @@ +-- write a SQL query to find the side (e.g., right or left) Babe Ruth hit. +SELECT "bats" FROM "players" WHERE "first_name" = "Babe" AND "last_name" = "Ruth"; diff --git a/3.sql b/3.sql new file mode 100644 index 0000000..462576d --- /dev/null +++ b/3.sql @@ -0,0 +1,2 @@ +-- write a SQL query to find the ids of rows for which a value in the column debut is missing. +SELECT "id" FROM "players" WHERE "debut" IS NULL; diff --git a/4.sql b/4.sql new file mode 100644 index 0000000..90b1ea3 --- /dev/null +++ b/4.sql @@ -0,0 +1,3 @@ +-- write a SQL query to find the first and last names of players who were not born in the United States. +-- Sort the results alphabetically by first name, then by last name. +SELECT "first_name", "last_name" FROM "players" WHERE "birth_country" != "USA" ORDER BY "first_name" ASC, "last_name" ASC; diff --git a/5.sql b/5.sql new file mode 100644 index 0000000..1779604 --- /dev/null +++ b/5.sql @@ -0,0 +1,3 @@ +-- write a SQL query to return the first and last names of all right-handed batters. +-- Sort the results alphabetically by first name, then by last name. +SELECT "first_name", "last_name" FROM "players" WHERE "bats" = "R" ORDER BY "first_name" ASC, "last_name" ASC; diff --git a/6.sql b/6.sql new file mode 100644 index 0000000..dfe1cce --- /dev/null +++ b/6.sql @@ -0,0 +1,3 @@ +-- write a SQL query to return the first name, last name, and debut date of players born in Pittsburgh, Pennsylvania (PA). +-- Sort the results first by debut date—from most recent to oldest—then alphabetically by first name, followed by last name. +SELECT "first_name", "last_name", "debut" FROM "players" WHERE "birth_city" = "Pittsburgh" ORDER BY "debut" DESC, "first_name" ASC, "last_name" DESC; diff --git a/7.sql b/7.sql new file mode 100644 index 0000000..81c2f1b --- /dev/null +++ b/7.sql @@ -0,0 +1,2 @@ +-- write a SQL query to count the number of players who bat (or batted) right-handed and throw (or threw) left-handed, or vice versa. +SELECT COUNT(*) FROM "players" WHERE "bats" = "R" AND "throws" = "L" OR "bats" = "L" AND "throws" = "R"; diff --git a/8.sql b/8.sql new file mode 100644 index 0000000..e69de29 diff --git a/9.sql b/9.sql new file mode 100644 index 0000000..e69de29