Public
Edited
Oct 26, 2023
11 forks
Insert cell
Insert cell
battingFile = FileAttachment("Batting.csv").csv({typed:true})
Insert cell
peopleFile = FileAttachment("People.csv").csv({typed:true})
Insert cell
managersFile = FileAttachment("Managers.csv").csv({typed:true})
Insert cell
db = DuckDBClient.of({
batting:battingFile,
people:peopleFile,
managers:managersFile
})
Insert cell
db
SELECT DISTINCT SO
FROM batting
WHERE SO NOT IN (
SELECT HR
FROM batting
)
Insert cell
db
SELECT DISTINCT sum(SO)
FROM batting
GROUP BY playerID
HAVING sum(SO) IN (
SELECT sum(HR)
FROM batting
GROUP BY playerID
)
Insert cell
db
SELECT DISTINCT nameFirst
FROM people
WHERE birthYear < 1950 AND nameFirst NOT IN (
SELECT nameFirst
FROM people
WHERE birthYear >= 1950
)
ORDER BY nameFirst DESC
Insert cell
db
SELECT nameFirst
FROM people
WHERE birthYear >= 1950
Insert cell
db
SELECT playerID
FROM batting
GROUP BY playerID
HAVING sum(HR) > 600
Insert cell
db
SELECT DISTINCT playerID
FROM batting b
WHERE 600 < (
SELECT sum(HR)
FROM batting
WHERE playerID = b.playerID
)
Insert cell
db
SELECT DISTINCT playerID
FROM managers
WHERE 300 < (
SELECT sum(HR)
FROM batting
WHERE playerID = managers.playerID
)
Insert cell
db
SELECT DISTINCT playerID
FROM batting
WHERE 10 = (
SELECT count(*)
FROM managers
WHERE playerID = batting.playerID
)
Insert cell
db
SELECT DISTINCT playerID
FROM batting
GROUP BY playerID
HAVING count(*) < (
SELECT count(*)
FROM managers
WHERE playerID = batting.playerID
)
Insert cell
db
SELECT DISTINCT playerID
FROM managers
GROUP BY playerID
HAVING count(*) > (
SELECT count(*)
FROM batting
WHERE playerID = managers.playerID
)
Insert cell
db
SELECT DISTINCT playerID
FROM managers
WHERE EXISTS (
SELECT playerID
FROM batting
WHERE playerID = managers.playerID
)
Insert cell
db
SELECT DISTINCT playerID
FROM managers
WHERE NOT EXISTS (
SELECT playerID
FROM batting
WHERE playerID = managers.playerID
)
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more