If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > how to get values to print horizontally?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-14-03, 14:39
prodell prodell is offline
Registered User
 
Join Date: Nov 2003
Posts: 1
how to get values to print horizontally?

Let's say I do this:

select name, class from student;

name class
---- -----
John english
John history
John math
John computer

but now i want data (class field) to print horizontally like below. how do i do it?

name class class class class
---- ------- ------- ------ --------
John english history math computer

thanks so much.
Reply With Quote
  #2 (permalink)  
Old 11-18-03, 14:38
mkkmg mkkmg is offline
Registered User
 
Join Date: Oct 2003
Location: Dallas
Posts: 76
well I know no simple answer.

but if you know the different type of classes you could do a case, or you could build a table then update it.

select user,
class1 = case when class = 'ENGLISH' then class else 'NONE' end,
class2 = case when class = 'MATH' then class else 'NONE' end,
class3 = case when class = 'HISTORY' then class else 'NONE' end,
class4 = case when class = 'COMPUTER' then class else 'NONE' end
from TABLE

That is not that great of a solution, but maybe point you in a direction to get started.
Reply With Quote
  #3 (permalink)  
Old 11-20-03, 06:36
orababa@kshema orababa@kshema is offline
Registered User
 
Join Date: Nov 2003
Location: Bangalore,India
Posts: 51
Re: how to get values to print horizontally?

you can use command like
select 1,(select class from) as firstfield,(select ....) secondfield......
from dual

it works if you have the fixed number of classes....Otherwise also you can construct through pl/sql .
Better soln would be create a table and insert the values before running the report
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On