All Forums Database
msanish 3 posts Joined 01/14
17 Feb 2014
SQL

Hi 
I've a one-many cardinality situation. Two tables have pk and fk relationship, for a given primary id there will be 25 max rows in the child table. I need to generate an extract report with one record meaning is that for one-id 25 columns from child table should retrieve to a one row as a output. 
for example.
Parent table
1
2
3
4
 
Child table
col1 col2
1     a    
1     b    
1     c   
1     d       
....
.....
1    y
upto 25 records for one given id
 
 
now i need output file as
1 a b c d ......y row values in one single output record
 
Appreciate your help in advance
Thanks
Manju
 
 
 

Adeel Chaudhry 773 posts Joined 04/08
17 Feb 2014

It seems to be a simple transpose case, for which following are some related threads on forum:
 
http://forums.teradata.com/forum/database/transpose-rows-to-columns-0
http://forums.teradata.com/forum/database/how-to-transpose-rows-to-columns-without-the-use-of-sql-and-bteqs
 
Dieter's replies should help you resolve this.
 
HTH!

-- If you are stuck at something .... consider it an opportunity to think anew.

You must sign in to leave a comment.