bot50
2026-04-27 15:09:09 +00:00
commit 3688d2f023
13 changed files with 76 additions and 0 deletions

9
5.sql Normal file
View 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;