Rolling up multiple rows into one in SQL
Rolling up multiple rows into one in SQL How do I roll the values (preferably using PL/SQL) in different columns for same person A into one column? I want to convert this: NAME SUB1 SUB2 SUB3 SUB4 A PASS A PASS A PASS A PASS into : NAME SUB1 SUB2 SUB3 SUB4 A PASS PASS PASS PASS I tried to use 'stuff' funciton but that would only be good to club all values under one field. Is there a way to do this? Why do you want a stored procedure? This can be done using plain SQL – a_horse_with_no_name Aug 24 at 20:53 1 Answer 1 Bunch of MAXs does the job (at least, according to what you posted so far). SQL> with test (name, sub1, sub2, sub3, sub4) as 2 (select 'a', null, null, null, 'pass' from dual union all 3 select 'a', null, null, 'pass', null from dual union all 4 select 'a', null, 'pass', null, null from dual union all 5 select 'a', 'pass', null, null, null from dual 6 ) 7 select name, max...