From 0eeee159cab36361bb62ae49785d2672cd591514 Mon Sep 17 00:00:00 2001 From: bot50 Date: Thu, 23 Apr 2026 15:10:05 +0000 Subject: [PATCH] daviddoji-cs50/problems/2024/sql/dese@20260423T151005.532787120Z --- 1.sql | 2 ++ 10.sql | 0 11.sql | 0 12.sql | 0 13.sql | 0 2.sql | 2 ++ 3.sql | 2 ++ 4.sql | 10 ++++++++++ 5.sql | 9 +++++++++ 6.sql | 9 +++++++++ 7.sql | 0 8.sql | 0 9.sql | 0 13 files changed, 34 insertions(+) create mode 100644 1.sql create mode 100644 10.sql create mode 100644 11.sql create mode 100644 12.sql create mode 100644 13.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..1b8a098 --- /dev/null +++ b/1.sql @@ -0,0 +1,2 @@ +-- write a SQL query to find the names and cities of all public schools in Massachusetts. +SELECT "name", "city" FROM "schools" WHERE "type" = "Public School"; diff --git a/10.sql b/10.sql new file mode 100644 index 0000000..e69de29 diff --git a/11.sql b/11.sql new file mode 100644 index 0000000..e69de29 diff --git a/12.sql b/12.sql new file mode 100644 index 0000000..e69de29 diff --git a/13.sql b/13.sql new file mode 100644 index 0000000..e69de29 diff --git a/2.sql b/2.sql new file mode 100644 index 0000000..7b0a4ca --- /dev/null +++ b/2.sql @@ -0,0 +1,2 @@ +-- write a SQL query to find the names of districts that are no longer operational. +SELECT "name" FROM "districts" WHERE "name" LIKE "%(non-op)"; diff --git a/3.sql b/3.sql new file mode 100644 index 0000000..bc2d051 --- /dev/null +++ b/3.sql @@ -0,0 +1,2 @@ +-- write a SQL query to find the average per-pupil expenditure. Name the column “Average District Per-Pupil Expenditure”. +SELECT AVG("per_pupil_expenditure") AS "Average District Per-Pupil Expenditure" FROM "expenditures"; diff --git a/4.sql b/4.sql new file mode 100644 index 0000000..c614136 --- /dev/null +++ b/4.sql @@ -0,0 +1,10 @@ +-- write a SQL query to find the 10 cities with the most public schools. +-- Your query should return the names of the cities and the number of public schools within them, +-- ordered from greatest number of public schools to least. If two cities have the same number of public schools, +-- order them alphabetically. +SELECT "city", COUNT(*) AS "Number of schools" +FROM "schools" +WHERE "type" = "Public School" +GROUP BY "city" +ORDER BY "Number of schools" DESC, "city" ASC +LIMIT 10; diff --git a/5.sql b/5.sql new file mode 100644 index 0000000..86540ed --- /dev/null +++ b/5.sql @@ -0,0 +1,9 @@ +-- write a SQL query to find cities with 3 or fewer public schools. Your query should return the names of the cities +-- and the number of public schools within them, ordered from greatest number of public schools to least. +-- If two cities have the same number of public schools, order them alphabetically. +SELECT "city", COUNT(*) AS "Number of schools" +FROM "schools" +WHERE "type" = "Public School" +GROUP BY "city" +HAVING COUNT(*) <= 3 +ORDER BY "Number of schools" DESC, "city" ASC; diff --git a/6.sql b/6.sql new file mode 100644 index 0000000..1e62ab7 --- /dev/null +++ b/6.sql @@ -0,0 +1,9 @@ +-- write a SQL query to find the names of schools (public or charter!) that reported a 100% graduation rate. +SELECT "name" +FROM "schools" +WHERE "id" IN ( + SELECT "school_id" + FROM "graduation_rates" + WHERE "graduated" = 100 + ) +; diff --git a/7.sql b/7.sql new file mode 100644 index 0000000..e69de29 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