0

I'm looking for a way to convert rows to columns in SQL server.

This is my two Tables:

"Decisions"

D_Id    R_ID    Level_ID     L_Date       Decision_S
 1      ch3     1            5/5/2015     Approved
 2      ch3     2            5/6/2015     Approved
 3      ch3     3            5/9/2015     Refused

"Request"

 R_Type                      ID       Creation_Date
 Appropriation Request       ch3      5/3/2015

I want to get this result:

R_ID    Creation_Date  Level1_Date   Level2_Date  Level3_Date
ch3     5/3/2015       5/5/2015      5/6/2015     5/9/2015

How can I build the result?

N.B:


The problem is i have to select from two tables at the same time, Where 'R_Id' equals 'ID' so it displays the 'R_Type', 'Level1_Date', 'Level2_Date' and other 'column headers' which they don't exist in both Tables.

  • Look up pivot or dynamic pivot. This has been answered dozens and dozens of times every week. – Sean Lange May 14 '15 at 18:40
  • The problem is i have to select from two tables at the same time, Where 'R_Id' equals 'ID' so it displays the 'R_Type', 'Level1_Date', 'Level2_Date' and other 'column headers' which they don't exist in both Tables. – el asraoui youness May 15 '15 at 10:19
  • The fact that the data is in two tables doesn't make any difference. It is still just a dynamic cross tab or dynamic pivot. – Sean Lange May 15 '15 at 13:14

0 Answers0