if first.account_number then session=1; *(or first.id or whatever...);
You just need to reinitialize at each new ID. (You may need to initialize more frequently than that - like every channel). I'm not sure how your example data correlates with your code, so you may need to modify your BY statement to reflect it correctly. For your example information, you need
by id channel;
at minimum - so you can say
if first.channel then session=1;
as it looks like you need to reset for each channel.