Madhukar Krishna

Madhukar Krishna

  • 904
  • 1.2k
  • 62.3k

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)