我的代码:如何获得另一列的项目值=值的列的总和?
string hweight = "Hunters";
string hsql = "SELECT SUM(Weight), Product From Opened WHERE Product =" + hweight;
OleDbCommand hcmd = new OleDbCommand(hsql,conn);
txtHunters.Text = hcmd.ExecuteScalar().ToString();
然后我收到以下错误:
You tried to execute a query that does not include the specified expression 'Product' as part of an aggregate function.
您缺少'group by'子句。 –
和你的字符串的SQL引号。 –
http://en.wikipedia.org/wiki/Aggregate_function –