lahmanlite/sql/halloffamereqs.sql

29 lines
657 B
MySQL
Raw Normal View History

pragma foreign_keys = 0;
2024-01-27 18:58:48 +00:00
begin;
2024-01-29 01:07:59 +00:00
attach database 'baseball-raw.db' as 'raw';
2024-01-31 06:09:39 +00:00
create temp table if not exists "halloffamereqs" (
2024-01-27 18:58:48 +00:00
"yearID" numeric,
"votedBy" text,
"ballots" numeric,
"needed" numeric,
2024-01-29 01:07:59 +00:00
"needed_note" text
2024-01-27 18:58:48 +00:00
);
insert into halloffamereqs
select distinct yearid, votedby, ballots, needed, "needed_note"
2024-01-29 01:07:59 +00:00
from "raw".halloffame;
2024-01-31 06:09:39 +00:00
create table if not exists main."halloffamereqs" (
"year" numeric,
"votedBy" text,
"ballots" numeric,
"needed" numeric,
"needed_note" text,
primary key("year","votedBy"),
foreign key("year") references "seasons"("year")
);
insert into main.halloffamereqs select distinct * from temp.halloffamereqs;
2024-01-27 18:58:48 +00:00
commit;