Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Displaying row values horizontally

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Displaying row values horizontally
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    Post subject:
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    Post subject:
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: 680
Location: NJ

PostPosted: Tue Feb 05, 2008 9:55 am    Post subject: Reply to: Displaying row values horizontally
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    Post subject: Reply to: Displaying row values horizontally
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    Post subject:
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    Post subject: Reply to: Displaying row values horizontally
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts BI,TO=ZD Changing Values Tyler Dunbar DFSORT/ICETOOL 4 Tue Jul 25, 2017 12:12 am
No new posts Reg:Displaying the particular month o... bhavana yalavarthi All Other Mainframe Topics 4 Sat Jul 08, 2017 8:13 pm
No new posts Sorting of hex values Saurabh_mi DFSORT/ICETOOL 11 Thu May 25, 2017 3:49 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Compare two files and subtract values ameetmund DFSORT/ICETOOL 7 Fri Mar 31, 2017 3:35 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us