Skip to content

Instantly share code, notes, and snippets.

View juanitobanca's full-sized avatar
Bateando y programando.

JB juanitobanca

Bateando y programando.
View GitHub Profile
We can't make this file beautiful and searchable because it's too large.
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17
2018,28-10-2018,BOSRed Sox,Price,1606,+11,+0,=1617,52,5,LADDodgers,Kershaw,1576,+9,+24,=1609,48,1
2018,27-10-2018,BOSRed Sox,Rodriguez,1603,+0,+0,=1603,49,9,LADDodgers,Hill,1580,+4,+24,=1608,51,6
2018,26-10-2018,BOSRed Sox,Porcello,1605,–11,–2,=1592,44,2,LADDodgers,Buehler,1578,+21,+22,=1621,56,3
2018,24-10-2018,LADDodgers,Ryu,1580,–7,+0,=1573,38,2,BOSRed Sox,Price,1603,+9,+24,=1636,62,4
2018,23-10-2018,LADDodgers,Kershaw,1582,+14,+2,=1598,35,4,BOSRed Sox,Sale,1600,+50,+27,=1677,65,8
2018,18-10-2018,BOSRed Sox,Price,1596,+5,+0,=1601,40,4,HOUAstros,Verlander,1602,+29,+24,=1655,60,1
2018,17-10-2018,BOSRed Sox,Porcello,1593,–6,+0,=1587,43,8,HOUAstros,Morton,1606,–7,+24,=1623,57,6
2018,16-10-2018,BOSRed Sox,Eovaldi,1587,–1,–2,=1584,45,8,HOUAstros,Keuchel,1611,–20,+22,=1613,55,2
2018,14-10-2018,HOUAstros,Cole,1614,+14,+0,=1628,53,5,BOSRed Sox,Price,1585,+6,+24,=1615,47,7
1. Crear base de datos. "Create database baseball"
2. Correr: mysql -u juanito -pbanca baseball2 < baseball.sql
Jugador Strikeouts Temporadas AtBats Strikeouts/AtBats
Hector Garcia 4 5 43 0.0930
Fabian Lopez 5 2 49 0.1020
Wilfredo Arano 10 6 95 0.1053
Rafael Castaneda 5 3 43 0.1163
Dabiel Flores 6 3 46 0.1304
Fernando Rodriguez 6 6 46 0.1304
Noe Becerra 9 7 68 0.1324
Ricardo Vazquez 14 7 104 0.1346
Valentin Gamez 10 7 73 0.1370
Jugador Strikeouts Temporadas AtBats Strikeouts/AtBats
Baltazar Lopez 32 6 79 0.4051
Carlos Morales 17 5 44 0.3864
Carlos Rodriguez 21 6 55 0.3818
Lorenzo Mercado 13 5 40 0.3250
Gregorio Angulo 13 5 41 0.3171
Juvenal Ibarra 13 2 42 0.3095
WITH d AS (
SELECT
CONCAT(p.firstName, ' ', p.lastName) playerName,
SUM(IF(ab.event = 'Strikeout', 1, 0)) strikeouts,
COUNT(DISTINCT g.seasonId) seasons,
COUNT(1) total
FROM atbats ab
INNER JOIN actions s
ON ab.gamePk = s.gamePk
AND ab.atBatIndex = s.atBatIndex
Temporada Liga Bateador 1 BA Bateador 2 BA Diferencia
2016 LIDOM Ronny Rodriguez 0.30625 Ramon Torres 0.305732484 5.18E-04
2018.2 LMB Olmo Rosario 0.40825688 Yuniesky Betancourt 0.40625 0.00200688
2013 LIDOM Junior Lake 0.342857142 Juan Lagares 0.342105263 7.52E-04
2019 LIDOM Moises Sierra 0.348148148 Jordany Valdespin 0.340277777 0.007870371
WITH agg AS (
SELECT
seasonId,
majorLeagueId,
playerId,
atBats,
battingAverage,
RANK() OVER(
PARTITION BY
seasonId,
WITH d AS (
SELECT
playerId,
unintentionalWalks,
weightUnintentionalWalk,
singles,
weightSingle,
doubles,
weightDouble,
triples,
WITH homescored
AS (SELECT majorleagueid,
seasonid,
venueid,
teamid,
runs,
games
FROM agg_batting_stats
WHERE grouping_id = 126
AND gametype2 = 'RS'
With we As
(
Select *
From we_win_expectancy
Where seasonId = 2019
And majorLeagueId = 125
And groupingId = 13040
And perspective = 'BATTING'
And gameType2 = 'RS'
),