I like golf. Actually, I love golf. No...I'm completely obsessed with golf. I follow all of the tours, players, and news. I'll wake up at 3 o'clock in the morning on weekends to watch The Open Championship being played in Great Britain in July. It's OK, I don't expect you to understand.
As with any sport, in golf there is no end of statistics, scores, and mounds upon mounds of data to read. There is a specific type of scoring in golf called Match Play. The gist of the system is that two players playing against each other on the same course will record their score for each hole. The player with the lower (better) score on a hole will go "one up" and the player with the higher (worse) score will go "1 down". As play progresses the "up" and "down" scoring is cumulative. Once a player is "up" more points than there are holes remaining, that player has won the match as their opponent would be unable to win enough remaining holes to close the gap. If you'd like to read more about match play scoring you can do so here.
If you imagine how a golfer's scores would be recorded in a database table, a very simplified approach would be a table that looked like this.
PLAYER_SCORECARD
Player | Hole | Score |
Bob | 1 | 4 |
Bob | 2 | 4 |
Bob | 3 | 3 |
Bob | 4 | 3 |
Bob | 5 | 5 |
Bob | 6 | 5 |
Bob | 7 | 6 |
Bob | 8 | 3 |
Bob | 9 | 4 |
... |
and so on.
Typically, when the scores for a Match Play type match are displayed for two opponents, it is done in a "horizontal" manner.
Hole | 1 | 2 | 3 | ... |
1 up | 2 up | 1 up | ... | |
Bob | 3 | 2 | 4 | ... |
Joe | 4 | 3 | 3 | ... |
1 dn | 2 dn | 1 dn | ... |
Since the scores for players are not stored horizontally in our PLAYER_SCORECARD table this is a great example of how the PIVOT function introduced in 11g can be very helpful.