按C#中的错误分组 [英] Group by errors in C#

查看:111
本文介绍了按C#中的错误分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,伙计们正在研究c#并面临一个问题。 附加信息:您的查询不包含指定的表达式'项目名称'作为聚合函数的一部分。

我不知道并且我尝试了很多东西但是这个错误仍然存​​在请帮助并告诉我这是什么以及如何解决它

感谢提前



我尝试过:



Hello, Guys am working on c# and am facing an issue. "Additional information: Your query does not include the specified expression 'Item Name' as part of an aggregate function."
I don't know and I have tried many things but this error still there please help and tell me what is this and how can I resolve it
Thanks to Advance

What I have tried:

"    con_string.ConnectionString = @"Provider = Microsoft.ACE.OLEDB.12.0;Data Source =|DataDirectory|\Restaurant.accdb;Persist Security Info=False";
                            DataSet dsa = new DataSet();
                            DataTable dt = new DataTable();
                            dsa.Tables.Add(dt);
                            OleDbDataAdapter da = new OleDbDataAdapter();
                            da = new OleDbDataAdapter("SELECT sum(Column1) As [Item Price],[column2]As [Item Name],[column3]As [Table Name],[Flavours],[Customer Name],[Delivery Time],[Time] FROM Runtime Group by [column3]", con_string);
                            da.Fill(dt);
                            dataGridVaiew2.DataSource = dt;
                            con_string.Close();"

推荐答案

请看这里: SQL GROUP By和列'名称'在选择列表中无效因为......错误 [ ^ ]


您需要在GROUP BY子句中包含SELECT列中的列表列表并且与聚合函数无关。

您的查询应该看起来像 -

You need to include the list of columns in the GROUP BY clause which are available in the SELECT list and doesn't associated with an aggregate function.
Your query should look like-
SELECT sum(Column1) As [Item Price],[column2]As [Item Name],[column3]As [Table Name],[Flavours],[Customer Name],[Delivery Time],[Time] FROM Runtime Group by [column3],[column2],[Flavours],[Customer Name],[Delivery Time],[Time]





但是你得到的结果可能不是你所期望的。您只需要包含那些基本上需要的列。



请在这种情况下通过示例输出告诉我,以便我可以进一步提供帮助。



谢谢:)



But the result you will get probably is not what you expected. You need to include only those columns which are essentially needed.

Please let me know with a sample output in that case so that I can help further.

Thanks :)


这篇关于按C#中的错误分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆