This discussion is archived
2 Replies Latest reply: Jul 11, 2013 7:23 AM by riedelme RSS

SQL Query help - Select Multiple rows in each single row with multiple columns

user4487805 Newbie
Currently Being Moderated

I would like to select multiple rows in each row with multiple columns.

Here's the example-

Table Name: Policy_Details

Policy_no

Client_id

101

X101

102

Y103

101

X105

103

X108

101

X109

102

X205

........
........
.......

 

Table Name: Client_Details

Client_id

Company_Name

X101

ABC LTD

Y103

XYZ LTD

X105

TEST CO.

X108

PAUL & SONS

X109

TEST2 CO

X205

FIVE CO

........
.........

 

Output Required:

Policy_no

company_name1

company_name2

company_name 3

company_name4

101

ABC LTD

TEST CO

TEST2 CO

 

102

XYZ LTD

FIVE CO

 

 

....................

 

Basically, I would like to combine multiple rows into a single row with multiple columns.

In a real scenario there are huge no of records.

 

Can anyone please suggest how to do this. Is this possible though sql without pl sql?

 

Thanks

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points