Everpure interview question

Easy SQL query question, for loop question...