如何从数据表中获得总和? [英] how to get sum from data table?
本文介绍了如何从数据表中获得总和?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数据表。如何在此查询中添加sum函数?
var qry = 来自行 dtTempTbl.AsEnumerable()
orderby 行[ RowId] 升序
group 行 new {PositionID = rows [ ItemSubGroupId]} into grp
选择 grp.First();
解决方案
MSDN有一个很棒的网站,你可以找到很多有用的LINQ例子。
https://code.msdn.microsoft.com/LINQ-Aggregate-Operators-c51b3869 [ ^ ]
干杯!
datble.Compute(sum(RATE),1 = 1)); //其中rate是数据表中的列
您没有提供有关您尝试执行的操作的足够信息,因此我可以做的就是发送给您MSDN网站上的一个示例。
总和 - 分组[ ^ ]
如果这不是您的目标,请编辑您的问题并提供尽可能详细的信息,包括您尝试过的一些代码等。
I have a data table. how to add sum function to this query?
var qry = from rows in dtTempTbl.AsEnumerable()
orderby rows["RowId"] ascending
group rows by new { PositionID = rows["ItemSubGroupId"] } into grp
select grp.First();
解决方案
Hi,
MSDN has a great site where you can find many useful LINQ examples.
https://code.msdn.microsoft.com/LINQ-Aggregate-Operators-c51b3869[^]
Cheers!
datble.Compute("sum(RATE)", "1=1")); //where rate is a column inside the datatable
You haven't provided enough information about what you are trying to do, so with that in mind all I can do is send to you towards an example on the MSDN site.
Sum - Grouped[^]
If this isn't what you are after then please edit your question and provide as much detail as you can, including some code that you have tried etc.
这篇关于如何从数据表中获得总和?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文