SQL

Database

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

1 REPLY
Teradata Employee

Re: SQL

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-an...

Dieter's replies should help you resolve this.

HTH!