Marius Vasile

Marius Vasile

  • 592
  • 1.9k
  • 145.4k

Display sqlserver query result in a MS Chart Pie

Oct 10 2024 4:22 PM

I get data with 

string sqlQuery = "SELECT DATEPART(MONTH, tr.DataInitierii) AS Month," +
    "coalesce(SUM(CASE When Dep LIKE '1.1.0%' then 1 end),0) A1," +
    "coalesce(SUM(CASE When Dep LIKE '1.1.3%' then 1 end),0) A2," +
    "coalesce(SUM(CASE When Dep LIKE '1.1.4%' then 1 end),0) A6," +
    "coalesce(SUM(CASE When Dep LIKE '1.1.5%' then 1 end),0) A8," +
    "coalesce(SUM(CASE When Dep LIKE '1.1.7%' then 1 end),0) A19," +
    "coalesce(SUM(CASE When Dep LIKE '1.2%' then 1 end),0) A20," +
    "coalesce(SUM(CASE When Dep LIKE '1.5%' then 1 end),0) A21," +
    "coalesce(SUM(CASE When Dep LIKE '1.6%' then 1 end),0) A22," +
    "coalesce(SUM(CASE When Dep LIKE '1.7%' then 1 end),0) A23 " +
    "FROM tblRCA_Import tr FULL JOIN tblClasificare tc ON tr.RCA# = tc.RCA# " +
    "WHERE DATEPART(YEAR, tr.DataInitierii)=@CurrentYear AND tc.Specialitate = @Spec GROUP BY DATEPART(MONTH, tr.DataInitierii)";

I display the data in a table but I want to display in a Pie Chart as well, using A1, A2...A23 values. How can I do that?


Answers (2)