For the following query, the select statement alone appears to be working correctly and when it goes through the loop the first time it is correct. It continues to select th