1

This is my table values:

-----------------------------
   id | rackname | routeid |
-----------------------------
  1   | rack1    |   1    
  2   | rack2    |   1
  3   | rack3    |   2
  4   | rack4    |   1
  5   | rack5    |   2
  6   | rack6    |   1
  .
  .
  .

I need to select only one row form this table that need to select all the values based on routeid using SQL Server 2014.

I need to generate a row like this..

---------------------------------------------------
id  | rackname1 | rackname2 | rackname3 | rackname4....
---------------------------------------------------
 1  | rack1     | rack2     | rack4     | rack6    ...

How to generate this result? Thanks in advance.

1 Answers1

1

You can do with PL/SQL

Declare table type variable (At the end you need to pivot on this variable so make sure for structure).

Now push desire data on this table.

Then pivot this table.

Bhavik Jani
  • 180
  • 7