This commit is contained in:
2
1.sql
Normal file
2
1.sql
Normal file
@@ -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";
|
||||
9
10.sql
Normal file
9
10.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
-- write a SQL query to find the 10 public school districts with the highest per-pupil expenditures.
|
||||
-- Your query should return the names of the districts and the per-pupil expenditure for each.
|
||||
SELECT d."name", e."per_pupil_expenditure"
|
||||
FROM "expenditures" AS e
|
||||
JOIN "districts" AS d
|
||||
ON e."district_id" = d."id"
|
||||
WHERE d."type" = 'Public School District'
|
||||
ORDER BY e."per_pupil_expenditure" DESC
|
||||
LIMIT 10;
|
||||
2
2.sql
Normal file
2
2.sql
Normal file
@@ -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)";
|
||||
2
3.sql
Normal file
2
3.sql
Normal file
@@ -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";
|
||||
10
4.sql
Normal file
10
4.sql
Normal file
@@ -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;
|
||||
9
5.sql
Normal file
9
5.sql
Normal file
@@ -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;
|
||||
9
6.sql
Normal file
9
6.sql
Normal file
@@ -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
|
||||
)
|
||||
;
|
||||
8
7.sql
Normal file
8
7.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
-- write a SQL query to find the names of schools (public or charter!) in the Cambridge school district.
|
||||
-- Keep in mind that Cambridge, the city, contains a few school districts, but DESE is interested in the
|
||||
-- district whose name is “Cambridge.”
|
||||
SELECT s."name"
|
||||
FROM "schools" AS s
|
||||
JOIN "districts" AS d
|
||||
ON s."district_id" = d."id"
|
||||
WHERE d."name" = 'Cambridge';
|
||||
5
8.sql
Normal file
5
8.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
-- write a SQL query to display the names of all school districts and the number of pupils enrolled in each.
|
||||
SELECT d."name", e."pupils"
|
||||
FROM "expenditures" AS e
|
||||
JOIN "districts" AS d
|
||||
ON e."district_id" = d."id";
|
||||
8
9.sql
Normal file
8
9.sql
Normal file
@@ -0,0 +1,8 @@
|
||||
-- write a SQL query to find the name (or names) of the school district(s) with the single least number of pupils.
|
||||
-- Report only the name(s).
|
||||
SELECT d."name"
|
||||
FROM "expenditures" AS e
|
||||
JOIN "districts" AS d
|
||||
ON e."district_id" = d."id"
|
||||
ORDER BY "pupils" ASC
|
||||
LIMIT 1;
|
||||
Reference in New Issue
Block a user