I totally don't understand what the output you expect for this. Please provide the ACTUAL output you expect for your given sample. You may need to set up additional sample data (with expected outputs for each set) to fully demonstrate your requirements.
Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service