Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> REPOST: Re: Sqlplus vertical output
Yes, but it isn't pretty - you have to use a UNION query and I'm assuming
you will only want to display a single row -
SELECT mytable.a as col_head
FROM mytable
UNION
SELECT mytable.b as col_head
FROM mytable
UNION
SELECT mytable.c as col_head
FROM mytable
If you want more than row from the original mytable, you can use a subquery like this. There is probably a more efficient way to do this; I bill $150 / hr to find it ;) - this example will work on scott/tiger database. You need a UNION for each column.
SELECT colhead.col_head
FROM EMP en,
(select empno, ename as col_head from emp
UNION select empno, to_CHAR(empno) as col_head from emp) colheadWHERE en.empno = colhead.empno
Tom
www.oraclepower.com
"Sauronatmordor" <csaba_at_securities.com> wrote in message
news:e919dfc1.0201250842.6d670352_at_posting.google.com...
> Oracle Gurus...
>
> Is there any way to move away from the usual horizontal output of
> sqlplus and get it to output records vertically? Like instead of
>
> selec a,b,c from mytable;
>
> a b c
> - - -
>
> 5 6 7
>
> I want:
> a: 5
> b: 6
> c: 7
>
> Reading through the formatting docs doesn't give me any idea.
> Thanks a lot.
> Csaba
>
This message was cancelled from within The Unacanceller's glorious new software, Lotus 1-2-3 For Rogue Cancellers. Received on Fri Jan 25 2002 - 10:54:58 CST