Well, start by identify the logic. So, you have an ID with only one record. What would you do in this instance? Currently the wholse of the second part of the if is ignored for these rows, what exactly is the "else" to avoid? Maybe take the else out and let the second part of the code run on everything, however for row 1 your likely then to get two rows output. Perhaps you could have another if that says if first.id and last.id then do ...; else do...;
... View more