RE: Display Rows as Columns

RE: Display Rows as Columns

 

  

select max(case when name='a' then (sub1+sub2)/2 else null end) as "a" ,
max(case when name='b' then (sub1+sub2)/2 else null end) as "b" ,
max(case when name='c' then (sub1+sub2)/2 else null end) as "c"
from students
/

HTH
Ofer

-----Original Message-----
From: Subin John
[mailto:oracledba-ezmlmshield-x2870194.[Email address protected]
Sent: Wednesday, June 30, 2004 1:19 PM
To: LazyDBA Discussion
Subject: Display Rows as Columns


 Hi gurus,

Can i make my rows as the columns in a oracle database.
eg:
i have a table for marks scored by students

name sub1 sub2
---- ---- ----
a 50 60
b 70 90
c 65 85

i need a report with the names as my column heading
with some avg marks of each one as

a b c
-- --- ---
55 80 75

is it possible? in which version?
if yes how?

thanks
Subin


--------
website: http://www.LazyDBA.com
Please don't reply to RTFM questions
Oracle documentation is here: http://tahiti.oracle.com
To unsubscribe: see http://www.lazydba.com/unsubscribe.html
To subscribe: send a blank email to oracledba-[Email address protected]
By using this list you agree to these
terms:http://www.lazydba.com/legal.html


**********************************************************************
The information contained in this e-mail message may be
privileged and confidential. The information is intended only
for the use of the individual or entity named above. If the
reader of this message is not the intended recipient, you are
hereby notified that any dissemination, distribution or copying
of this communication is strictly prohibited. If you have
received this communication in error, please notify us
immediately by telephone, or by e-mail and delete the message
from your computer. Thank you!
Unless otherwise stated, any views or opinions expressed in
this e-mail are solely those of the author and do not represent those of
Barak I.T.C (1995) The International Telecommunications Services Corp. Ltd.
**********************************************************************


Oracle LazyDBA home page