Add SQL logic for the team league