lahmanlite/sql/homegames.sql

33 lines
787 B
MySQL
Raw Normal View History

2024-01-26 19:27:58 +00:00
begin;
2024-01-31 06:09:39 +00:00
attach database 'baseball-raw.db' as 'raw';
create temp table homegames as
select * from "raw".homegames;
2024-01-26 19:27:58 +00:00
alter table "homegames" drop column "league.key";
update homegames
set "team.key" = 'WS9'
where "team.key" = 'WAS' and "year.key" between 1891 and 1899;
update homegames
set "team.key" = 'PHP'
where "team.key" = 'PH4' and "year.key" between 1890 and 1891;
2024-01-31 06:09:39 +00:00
CREATE TABLE IF NOT EXISTS main."homegames" (
"year" NUMERIC,
"team" TEXT,
"park" TEXT,
"first" TEXT,
"last" TEXT,
"games" NUMERIC,
"openings" NUMERIC,
"attendance" NUMERIC,
PRIMARY KEY("year","team","park"),
foreign key("park") references "parks"("ID"),
foreign key("year","team") references "teamseasons"("year","team")
);
insert into main.homegames select distinct * from temp."homegames";
2024-01-26 19:27:58 +00:00
commit;