In each case, the sum of any column, regardless of the number of rows, will only ever add up to 1. And the max number of rows could only ever be 10. Hence the question is, how do i merge these rows into one row in each case, so that the first case would look like:

alpha bravo charlie delta echo foxtrot1 1 1 1 1 NULL

similarly the second case would become:

alpha bravo charlie delta echo foxtrotNULL NULL 1 NULL 1 1

and so forth. Is there neat a way to do this, bare in mind that there are 40 plus columns in the database?