This week I rewrote the SQL to calculate the win loss averages for the Snooker players. The old version using the old database design ran to 40 lines of case and if statements. It was severely limited by my database knowledge several years ago.
The new version is a dozen lines, that has a nested query to calculate the percentages from aliases that count the scores. It delivers all the information ready to be output to the screen by the HTML class. Tidy.