Public
Edited
Oct 16, 2023
Insert cell
Insert cell
peopleFile = FileAttachment("People.csv").csv({typed:true})
Insert cell
collegeFile = FileAttachment("CollegePlaying.csv").csv({typed:true})
Insert cell
managersFile = FileAttachment("Managers.csv").csv({typed:true})
Insert cell
battingFile = FileAttachment("Batting.csv").csv({typed:true})
Insert cell
Insert cell
db
SELECT nameFirst,nameLast,
CASE birthCountry
WHEN 'USA' THEN 'USA'
ELSE 'INTERNATIONAL'
END BirthPlace
FROM people

Insert cell
db
SELECT nameFirst,nameLast,
CASE (concat(bats,throws))
WHEN 'RR' THEN 'bats right, throws right'
WHEN 'LL' THEN 'bats left, throws left'
WHEN 'RL' THEN 'bats right, throws left'
WHEN 'LR' THEN 'bats left, throws right'
END
FROM people

Insert cell
db
SELECT playerID,count(DISTINCT schoolID) AS schools
FROM college
GROUP BY playerID
ORDER BY schools DESC

Insert cell
db
SELECT playerID,schoolID
FROM college
WHERE playerID = 'baumgro01'
GROUP BY playerID,schoolID
Insert cell
db
SELECT playerID,
CASE(count(DISTINCT schoolID))
WHEN 1 THEN 'ONE COLLEGE'
WHEN 2 THEN 'TWO COLLEGES'
WHEN 3 THEN 'THREE COLLEGES'
END colleges
FROM college
GROUP BY playerID


Insert cell
db
SELECT playerID,
IFNULL((SELECT
CASE
WHEN count(DISTINCT schoolID) = 1 THEN 'ONE COLLEGE'
WHEN count(DISTINCT schoolID) = 2 THEN 'TWO COLLEGES'
WHEN count(DISTINCT schoolID) = 3 THEN 'THREE COLLEGES'
END colleges
FROM college
WHERE playerID = people.playerID
),'NO COLLEGE') info
FROM people


Insert cell
db
SELECT playerID,schoolID
FROM college
WHERE playerID = 'conroti01'
Insert cell
db
SELECT playerID
FROM people
WHERE nameLast = 'Conroy'
Insert cell
db
SELECT playerID,
CASE
WHEN (SELECT count(*)
FROM managers
WHERE playerID = people.playerID) = 0 THEN 'NEVER MANAGED'
ELSE (SELECT count(*)
FROM managers
WHERE playerID = people.playerID)
END
from people
Insert cell
db
SELECT playerID,yearID
FROM managers
WHERE playerID = 'aloufe01'
Insert cell
db
SELECT playerID,
IFNULL((SELECT
CASE(count(DISTINCT schoolID))
WHEN 1 THEN 'ONE COLLEGE'
WHEN 2 THEN 'TWO COLLEGES'
WHEN 3 THEN 'THREE COLLEGES'
END colleges
FROM college
WHERE playerID = people.playerID
),'NO COLLEGE') info
FROM people
Insert cell
db
SELECT playerID,
IFNULL((SELECT
CASE(count(DISTINCT schoolID))
WHEN 1 THEN 'ONE COLLEGE'
WHEN 2 THEN 'TWO COLLEGES'
WHEN 3 THEN 'THREE COLLEGES'
END colleges
FROM college
WHERE playerID = people.playerID
),'NO COLLEGE') info
FROM people
Insert cell
db
SELECT playerID,
CASE
WHEN not exists(SELECT playerID
FROM managers
WHERE playerID = people.playerID) THEN 'N'

ELSE 'Y'
END
FROM people
Insert cell
db
SELECT playerID,H,AB,
CASE
WHEN AB = 0 THEN 'no average'
ELSE H/AB
END avg
FROM batting
ORDER BY avg
Insert cell
db
SELECT playerID,nameFirst,nameLast,
CASE
WHEN birthYear IS NULL THEN 'unknown'
ELSE floor(birthYear)
END
FROM people


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