-- Test data:
declare @a as table
(
row1 int,
row2 int,
row3 int,
row4 int
);
insert @a values (0,6,0,0);
insert @a values (0,0,30,0);
insert @a values (4,0,0,0);
insert @a values (0,0,0,18);
--select * from @a;
-- Example solution:
select
max(case when row1 <> 0 then row1 end) as Row1,
max(case when row2 <> 0 then row2 end) as Row2,
max(case when row3 <> 0 then row3 end) as Row3,
max(case when row4 <> 0 then row4 end) as Row4
from @a