While Loop In Sql Select Statement