strSQL = "SELECT * FROM"+
"("+
"SELECT kpiDesc,COALESCE(performance,0)as performance,MONTH(kpiDate) AS months" +
" FROM table1 LEFT JOIN "+
"table2 ON table1.kpiID = table2e.kpiID"+
" WHERE MONTH(kpiDate) IN(1,2,3,4,5,6,7,8,9,10,11,12)"+
" AND empID = @user"+
" AND kpiRound =2012"+
") as tblpvt"+
" PIVOT (SUM(tblpvt.performance) for tblpvt.months IN ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12])) as pvt ORDER BY kpiDesc";
...............................................................................
//*** KPI January ***//
Label lblMonth1 = (Label)(e.Item.FindControl("lblMonth1"));
if (lblMonth1 != null)
{
lblMonth1.Text = (string)DataBinder.Eval(e.Item.DataItem, "[1]");
}
Tag : ASP.NET Ms SQL Server 2008, HTML/CSS, Web (ASP.NET), C#