IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Displaying row values horizontally


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
NeeluJoshi

New User


Joined: 12 Dec 2007
Posts: 8
Location: Florida

PostPosted: Tue Feb 05, 2008 3:15 am
Reply with quote

Hi,

I have two tables

Student(Studentid,studentname)
Course(studentid, courseid)

For one student id there can be many courseids

I want to join these two tables and display the results like
Studentid1 courseid1 courseid2 courseid3
Studentid2 courseid3 courseid4

Can anyone help me on this.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Tue Feb 05, 2008 3:28 am
Reply with quote

Impossible with a single query.
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Tue Feb 05, 2008 3:29 am
Reply with quote

The biggest limitation is that the number of courses per student varies and you need to select all the return fields in the ... of the the SELECT ... FROM statement.
Back to top
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Tue Feb 05, 2008 9:55 am
Reply with quote

I dont think it 's possible
Back to top
View user's profile Send private message
rag swain

New User


Joined: 17 Dec 2007
Posts: 33
Location: pune,INDIA

PostPosted: Tue Feb 05, 2008 9:07 pm
Reply with quote

Can you show some data from both the tables? Are there other columns related to course_id in COURSE table
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Tue Feb 05, 2008 9:14 pm
Reply with quote

You need to do this in a post processing program.

The O/P gave the format of the original data. You can come up with your own dataset based on what they gave.

Here, I'll give you one.

Code:

--student table
Studentid studentname
---------- -----------
11111      Bob Jones
12345      John Doe

--Course table
studentid courseid
--------- --------
11111         123
11111         124
11111         125
11111         127
11111         128
11111         129
11111         130
11111         200
12345         123
12345         124
Back to top
View user's profile Send private message
rag swain

New User


Joined: 17 Dec 2007
Posts: 33
Location: pune,INDIA

PostPosted: Tue Feb 05, 2008 9:49 pm
Reply with quote

Why not thru a program? Is this a real time scenario/request ,OR, just out of curiosity ,OR, are you trying to generate a formatted report as part of adhoc request thru QMF? Crazy one without program!
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts IBM OnDemand Folders displaying to al... IBM Tools 6
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
Search our Forums:

Back to Top