Join Two Tables and calculate SUM of Column in SQL Server

Last Reply 2 months ago By pandeyism

Posted 3 months ago


I want yo generate a chart using data from two tables. I developed the code in Visual Studio, C# and I took the code for chart from this site.

I had two tables: Invoices and Costs.

Invoices contains: category,due_date, sum.

Costs contains: category, date, sum.

I select a month from Costs and then I want to display on the chart the total sum of the tables and all the categories once time.

How can I write the SQL query?

I share with you my current query on Costs table.

 string query = string.Format("select distinct Categorie,sum(C_Suma) from Cheltuieli where  datename(month,C_Data) = '{0}' group by Categorie", ddlLuna.SelectedValue);

The code is in Romanian, I translate above the terms.

Thank you!

This question does not have replies marked as Answer.