Depending on situation, there are two ways to achieve that:
1. On SQL server side - using
PIVOT[
^]
SELECT ID, [Name], [2013], [2014], [2015]
FROM (
SELECT ID, [Name], [Year], Enroll
FROM YourTable
) AS SRC
PIVOT(MAX(Enroll) FOR [Year] IN ([2013], [2014], [2015])) AS PVT
How to use it? See:
How to: Create and Execute an SQL Statement that Returns Rows[
^]
2. On application level - using Linq query
Pivoting DataTable Simplified[
^]
C# LINQ Pivot() Function - Reflection IT[
^]
Using lambda or LINQ for pivot tables[
^]