{"id":220,"date":"2018-03-27T13:13:09","date_gmt":"2018-03-27T20:13:09","guid":{"rendered":"http:\/\/www.ootp.cavebutter.net\/blog\/?p=220"},"modified":"2018-03-28T07:53:29","modified_gmt":"2018-03-28T14:53:29","slug":"pitching-stats-1-the-easy-stuff","status":"publish","type":"post","link":"http:\/\/www.ootp.cavebutter.net\/blog\/archives\/220","title":{"rendered":"Pitching Stats 1: The Easy Stuff"},"content":{"rendered":"<p>Here&#8217;s the same explanation of how the stats tables are organized as we used in the first Batting Stats post:<\/p>\n<blockquote><p>Stats are collected for each player who accumulates them. \u00a0Each player gets his own row. \u00a0For each year that a player accumulates stats, a new row of data is created for that player. \u00a0For each team that a player plays in a given year (stint), a new row of data is created for that player. \u00a0Stats are accumulated and placed into three splits for each player-year-stint: Overall, vs. Left, and vs. Right.<\/p><\/blockquote>\n<p>As we did for the batting stats, we&#8217;ll be creating a new table for all of the pitching stats together in one place; counting stats provided by the game and calculated stats that we&#8217;ll derive here.<\/p>\n<p>We&#8217;re carrying over all of the counting stats, plus WPA and WAR. \u00a0The calculated stats we&#8217;re adding in this post fall in the category of Easy Stuff:<\/p>\n<ul>\n<li>InnPitch &#8211; I set this as a variable to avoid having to elaborate every time.\u00a0This is the IP integer plus the IPF (innings pitched fraction) x 0.33\n<pre class=\"line-numbers\"><code class=\"language-markup\">round(IP + (IPF * .33),1).<\/code><\/pre>\n<\/li>\n<li>All of the &#8220;x9&#8221; stats: K\/9, BB\/9 etc.<\/li>\n<li>WHIP<\/li>\n<li>GB\/FB &#8211; Ground Ball\/Fly Ball outs<\/li>\n<li>BABIP (see the <a href=\"http:\/\/www.ootp.cavebutter.net\/blog\/archives\/166\">batting post<\/a> for more on this)<\/li>\n<li>ERA<\/li>\n<\/ul>\n<p>Here&#8217;s the code:<\/p>\n<pre class=\"line-numbers\"><code class=\"language-sql\">DROP TABLE IF EXISTS CalcPitching;\r\nCREATE TABLE IF NOT EXISTS CalcPitching AS\r\n\r\nSELECT\r\n    i.player_id\r\n    , i.year\r\n    , i.stint\r\n    , i.team_id\r\n    , i.league_id\r\n    , split_id\r\n    , i.ip\r\n    , i.ab\r\n    , i.tb\r\n    , i.ha\r\n    , i.k\r\n    , i.bf\r\n    , i.rs\r\n    , i.bb\r\n    , i.r\r\n    , i.er\r\n    , i.gb\r\n    , i.fb\r\n    , i.pi\r\n    , i.ipf\r\n    , i.g\r\n    , i.gs\r\n    , i.w\r\n    , i.l\r\n    , i.s\r\n    , i.sa\r\n    , i.da\r\n    , i.sh\r\n    , i.sf\r\n    , i.ta\r\n    , i.hra\r\n    , i.bk\r\n    , i.ci\r\n    , i.iw\r\n    , i.wp\r\n    , i.hp\r\n    , i.gf\r\n    , i.dp\r\n    , i.qs\r\n    , i.svo\r\n    , i.bs\r\n    , i.ra\r\n    , i.cg\r\n    , i.sho\r\n    , i.sb\r\n    , i.cs\r\n    , i.hld\r\n    , i.ir\r\n    , i.irs\r\n    , i.wpa\r\n    , i.li\r\n    , i.outs\r\n    , i.war\r\n    , @InnPitch := round(i.ip + (i.ipf*.33),1) AS InnPitch\r\n    , round((9*i.k)\/@InnPitch,1) AS 'k9'\r\n    , round((9*i.bb)\/@InnPitch,1) AS 'bb9'\r\n    , round((9*i.hra)\/@InnPitch,1) AS 'HR9'\r\n    , round((i.bb+i.ha)\/@InnPitch,2) AS WHIP\r\n    , round(i.k\/i.bb,2) AS 'K\/BB'\r\n    , i.gb\/i.fb AS 'gb\/fb'\r\n    , round((i.ha-i.hra)\/(i.ab-i.k-i.hra-i.sh+i.sf),3) AS BABIP\r\n    , round((i.er\/@InnPitch)*9,2) AS ERA\r\n    \r\n    \r\nFROM players_career_pitching_stats AS i;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s the same explanation of how the stats tables are organized as we used in the first Batting Stats post: Stats are collected for each player who accumulates them. \u00a0Each player gets his own row. \u00a0For each year that a player accumulates stats, a new row of data is created for that player. \u00a0For each&hellip; <a class=\"more-link\" href=\"http:\/\/www.ootp.cavebutter.net\/blog\/archives\/220\">Continue reading <span class=\"screen-reader-text\">Pitching Stats 1: The Easy Stuff<\/span> <span class=\"meta-nav\" aria-hidden=\"true\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[29],"tags":[7,4,15,6],"class_list":["post-220","post","type-post","status-publish","format-standard","hentry","category-pitching","tag-mysql","tag-ootp","tag-pitching","tag-tables"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9cxb5-3y","jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/posts\/220","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/comments?post=220"}],"version-history":[{"count":5,"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/posts\/220\/revisions"}],"predecessor-version":[{"id":235,"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/posts\/220\/revisions\/235"}],"wp:attachment":[{"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/media?parent=220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/categories?post=220"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/tags?post=220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}