Suppose that I create T-SQL SELECT statement in a WHILE loop (say to iterate over year records). I have a total count of records in the SELECT, and a count of a subset of records matching certain criteria. Each loop iteration is added to a temp table as a new record. Suppose that I create T-SQL SELECT statement in