Modified SQL to handle ties in standings