Heh... I wonder how many people won't even try to answer because the test data is done using a cCTE to build a Tally Table and they don't know how it works. I hope those people use this question to learn what it does.
RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row. First step towards the paradigm shift of writing Set Based code: ________Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
"If you think its expensive to hire a professional to do the job, wait until you hire an amateur."--Red Adair
"Change is inevitable... change for the better is not." Helpful Links: How to post code problems How to Post Performance Problems Create a Tally Function (fnTally)