Sql Case When In Join Statement In Python