I have two tables: Incomings and Expenditures. Incomings has IncDate and IncCost and Expenditures has ExpDate and ExpCost. IncCost and ExpCost are stored as a double and IncDate and ExpDate are stored as a string dd/MM/yyyy (bad practice I know). I am trying to merge IncDate and ExpDate and sum up the costs for each day. I am trying to add this data to a datatable so that I can create a chart with it. The error I am getting says "Incorrect syntax near the keyword 'AS'" although that's all it says so it's not much use. Here is the code I am using to try and create this datatable
DataTable dt = new DataTable();
public DataTable DatatableNew()
{
SqlDataAdapter Adp = new SqlDataAdapter("select CONVERT(DATETIME, IncDate, 103) AS IncDate, SUM(IncCost) AS IncCost, CONVERT(DATETIME, ExpDate, 103) AS ExpDate, SUM(ExpCost) AS ExpCost from Incomings i FULL OUTER JOIN Expenditures e ON i.IncDate = e.ExpDate AS FinalDate GROUP BY CONVERT(DATETIME, FinalDate, 103) ORDER BY CONVERT(DATETIME, FinalDate, 103)", con);
dt.AcceptChanges();
Adp.Fill(dt);
return dt;
}
Any help is greatly appreciated. Cheers in advance