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 SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts Overlaying one set of charater values... Kevin Lindsley SYNCSORT 7 Sat Nov 05, 2016 3:21 am
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts How can we create a flat file in JAVA... rakesh.v18 Java & MQSeries 7 Fri Sep 23, 2016 10:46 pm
No new posts Using 'parm' to vary SORTOUT record v... Sysaron DFSORT/ICETOOL 13 Wed Sep 07, 2016 9:24 pm


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