Madhukar Krishna

Madhukar Krishna

  • 688
  • 1.4k
  • 292.2k

How to get a main column and multiple sub columns in SQL

Mar 28 2019 2:35 AM
I have a table in SQL Server which looks like this:
 
 STID SName   SMobile SAddress   SCollege
 1 Madhukar   6787687645  Mithapur Patna AN College 
 2 Divya   8796543456  Thane, Mumbai Pune College
 
I want it to look like this:
 
                        Madhukar                                 Divya
6787687645 | Mithapur, Patna |  AN College |8796543456  |Thane, Mumbai |Pune College
 
Is it possible in SQL? Any help would be appreciated. I have tried using pivot table but can't get the code right 

Answers (2)