lahmanlite/sql/managers.sql

34 lines
783 B
MySQL
Raw Normal View History

2024-01-28 05:14:56 +00:00
begin;
2024-01-31 06:09:39 +00:00
attach database 'baseball-raw.db' as 'raw';
create temp table managers as
select * from "raw".managers;
2024-01-28 05:14:56 +00:00
alter table managers drop column "lgID";
alter table managers drop column "rank";
update managers
set teamid = 'WS9'
where teamid = 'WAS' and yearid between 1891 and 1899;
update managers
set teamid = 'PHP'
where teamid = 'PH4' and yearid between 1890 and 1891;
2024-01-31 06:09:39 +00:00
CREATE TABLE IF NOT EXISTS main."managers" (
"ID" TEXT,
"year" NUMERIC,
"team" TEXT,
"inseason" NUMERIC,
"G" NUMERIC,
"W" NUMERIC,
"L" NUMERIC,
"plyrMgr" TEXT,
PRIMARY KEY("ID","year","team","inseason"),
foreign key("ID") references "people"("ID"),
foreign key("year","team") references "teamseasons"("year","team")
);
insert into main.managers select distinct * from temp."managers";
2024-01-28 05:14:56 +00:00
commit;