Let us assume a hypothetical situation in an MLB game. A pitcher gets to a 2-2 count against the batter. Then the pitcher leaves the game - perhaps he sustains an injury while delivering a pitch, or is ejected by an umpire. In this case, the offense is allowed to substitute a new pitcher during the at-bat because the old pitcher left due to injury or ejection.
Which pitcher is credited with the result of the at-bat? Does it matter what the count is? Clearly if the batter hits a home run that is the responsibility of the new pitcher, but if the batter walks after going 3-0, would the new pitcher be credited with the walk after the first pitcher put him in the hole? Same with 0-2 and getting a strikeout.
What do the official MLB rules say about this? Section 5.10 covers substitutions including some pitcher-specific rules, but I cannot find anything about during an at-bat. Section 9.16 is pretty thorough with regards to swapping pitchers between batters in ERA calculations, but I have been unable to find anything about pitching statistics where a single batter faces two pitchers during a single at-bat.