{"id":132,"date":"2017-09-28T09:05:26","date_gmt":"2017-09-28T16:05:26","guid":{"rendered":"http:\/\/www.ootp.cavebutter.net\/blog\/?p=132"},"modified":"2017-09-28T09:05:26","modified_gmt":"2017-09-28T16:05:26","slug":"run-environment-6-run-values-2","status":"publish","type":"post","link":"http:\/\/www.ootp.cavebutter.net\/blog\/archives\/132","title":{"rendered":"Run Environment 6: Run Values 2"},"content":{"rendered":"<p>The last table for our Run Environment set is almost exactly the same as the one I presented before with two differences: we&#8217;re returning the runMinus and RunPlus from the intermediate table, and we&#8217;re using a variable to define wOBAscale- making the whole thing much more elegant and easy to understand.<\/p>\n<pre class=\"line-numbers\"><code class=\"language-sql\"># The last Run Values table, returning fields from RunValues1A, defining wOBAscale\r\n# as a variable, and giving us the weighted factors by league year for batting events\r\nDROP TABLE IF EXISTS tblRunValues2;\r\nCREATE TABLE tblRunValues2 AS\r\nSELECT year\r\n, league_id\r\n, RperOut \r\n, runBB \r\n, runHB \r\n, run1B \r\n, run2B \r\n, run3B \r\n, runHR \r\n, runSB \r\n, runCS \r\n, runMinus \r\n, runPlus \r\n, wOBA \r\n, @ws := 1\/(runPlus+runMinus) AS wOBAscale \r\n, (runBB+runMinus)*@ws AS wobaBB \r\n, (runHB+runMinus)*@ws AS wobaHB \r\n, (run1B+runMinus)*@ws AS woba1B \r\n, (run2B+runMinus)*@ws AS woba2B \r\n, (run3B+runMinus)*@ws AS woba3B \r\n, (runHR+runMinus)*@ws AS wobaHR \r\n, runSB*@ws AS wobaSB \r\n, runCS*@ws AS wobaCS \r\nFROM tblRunValues1A;<\/code><\/pre>\n<p>This is the table that we&#8217;ll refer to when calculating wOBA for individual players, factoring wobaXX against their counting stats XX. \u00a0It&#8217;ll make more sense when we actually do it.<\/p>\n<p>This is almost all of the data we need to complete our batting stats. \u00a0What remains is park factor. \u00a0I had been hoping that we could use the factors listed on the parks table. \u00a0Unfortunately, OOTP&#8217;s resident MySQL Whisperer says <a href=\"http:\/\/www.ootpdevelopments.com\/board\/showpost.php?p=4235956&amp;postcount=2\">it&#8217;s not true<\/a>. I&#8217;m going to set that aside for today- while I figure out how to calculate park factors &#8211; and use an incremental approach to developing the batting stats view. \u00a0I figure that will give me one, maybe two, posts to get a good method for that.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The last table for our Run Environment set is almost exactly the same as the one I presented before with two differences: we&#8217;re returning the runMinus and RunPlus from the intermediate table, and we&#8217;re using a variable to define wOBAscale- making the whole thing much more elegant and easy to understand. # The last Run&hellip; <a class=\"more-link\" href=\"http:\/\/www.ootp.cavebutter.net\/blog\/archives\/132\">Continue reading <span class=\"screen-reader-text\">Run Environment 6: Run Values 2<\/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_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},"jetpack_post_was_ever_published":false},"categories":[23],"tags":[14,17,7,4,6],"class_list":["post-132","post","type-post","status-publish","format-standard","hentry","category-run-environment","tag-batting","tag-leagues","tag-mysql","tag-ootp","tag-tables"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9cxb5-28","jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/posts\/132","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=132"}],"version-history":[{"count":2,"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/posts\/132\/revisions"}],"predecessor-version":[{"id":134,"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/posts\/132\/revisions\/134"}],"wp:attachment":[{"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/media?parent=132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/categories?post=132"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ootp.cavebutter.net\/blog\/wp-json\/wp\/v2\/tags?post=132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}