SQL QUERY to Table Output

Hi
I am trying to run sql query from solaris in csh script and send the output to email. Below is my sql query

select p.spid,se.program seprogram, se.machine, se.username, sq.sql_text,sq.retrows from v$process p
inner join v$session se on p.addr = se.paddr
 inner join
( select se1.sid,s1.sql_text,CASE WHEN s1.rows_processed > 0 THEN round((s1.rows_processed/s1.executions),0) END retrows  from
              (select * from v$session where sql_address is not null) se1
      inner join v$sql s1 on se1.sql_address = s1.address and se1.sql_hash_value = s1.hash_value
  union
  select se2.sid,s2.sql_text,CASE WHEN s2.rows_processed > 0 THEN round((s2.rows_processed/s2.executions),0) END retrows from
              (select * from v$session where prev_sql_addr is not null) se2
      inner join v$sql s2 on se2.prev_sql_addr = s2.address and se2.prev_hash_value = s2.hash_value ) sq
            on sq.sid = se.sid
            where p.spid = $var;

Anyone can help to make the above sql query output in nicer format prefer in table format with border?

sqlplus has various format options which can generate almost anything format wise.

Check out this document :
Formatting SQL*Plus Reports

Have you tried some options it provides ?

Regards
Peasant.

You should decide if you want ASCII text output or HTML output for pretty printing.
For the latter, read the manual reg. SET MARKUP HTML ON/OFF .