Pregunta de entrevista de FactSet

Two coding questions that involved a simple while loop calculation. One fairly basic SQL question that I didn't answer completely because it isn't my area of expertise.