bot50
2026-04-27 15:41:07 +00:00
commit 173fe034b7
13 changed files with 132 additions and 0 deletions

21
13.sql Normal file
View File

@@ -0,0 +1,21 @@
-- write a SQL query to answer a question you have about the data! The query should:
--
-- Involve at least one JOIN or subquery
-- Which schools have the highest graduation rates in districts that spend less than the average per-pupil expenditure?
SELECT
s."name" AS "school",
d."name" AS "district",
e."per_pupil_expenditure",
g."graduated"
FROM "schools" AS s
JOIN "districts" AS d
ON s."district_id" = d."id"
JOIN "expenditures" AS e
ON d."id" = e."district_id"
JOIN "graduation_rates" AS g
ON s."id" = g."school_id"
WHERE e."per_pupil_expenditure" < (
SELECT AVG("per_pupil_expenditure")
FROM "expenditures"
)
ORDER BY g."graduated" DESC, s."name" ASC;