spool p1.out
set echo on 
break on s# on sname on status on scity on p_num  on pname on color on weight on pcity 
/*coLumn  s# NEWLINE*/
/*COlumn p_num NEWLINE*/ 
SET pagesize 66
set newpage 0
set head off
compute sum of qty on s#
compute sum of qty on p_num 
select distinct s.s#,s.sname,s.status,s.city scity,
'    '||p.p# p_num, p.pname,p.color,p.weight,p.city pcity,
'            '||j.j# j_num, j.jname,j.city jcity,qty
     from s,p,j,spj
    where s.s#=spj.s# and p.p#=spj.p# and j.j#=spj.j#
    order by s.s#, p_num,j_num;
commit;
spool off 
/

