I've Googled a lot but I can't quite figure this out. I apologize if this is a trivial question.
I would like to SELECT a row if the 'batter' column equals a certain value AND the next row is not the same batter. I'm trying to get the row that represents the final pitch of the at bat. If it is the final pitch, then the next row would be a new batter. I'm using an auto-incremented id column if that helps.
EDIT:
Here's how the data is organized. Right now if I want to know how many times batter "276055" struck out I would do:
SELECT * FROM `mlb2012` WHERE batter = "276055" AND atbat_event = "strikeout" AND atbat_pitch = "1"
But if I want to know how many times he struck out looking, I would need to know the pitch_des of the last pitch of the atbat.
ID | Batter | atbat_pitch | atbat_event | pitch_des |
----------------------------------------------------------
1 | 457477 | 1 | Double | Called Strike
2 | 457477 | 2 | Double | In play, no out
3 | 452121 | 1 | Strikeout | Foul
4 | 452121 | 2 | Strikeout | Foul
5 | 452121 | 3 | Strikeout | Called Strike
6 | 543569 | 1 | Walk | Ball