• <legend id='2uhwh'><style id='2uhwh'><dir id='2uhwh'><q id='2uhwh'></q></dir></style></legend>
    <i id='2uhwh'><tr id='2uhwh'><dt id='2uhwh'><q id='2uhwh'><span id='2uhwh'><b id='2uhwh'><form id='2uhwh'><ins id='2uhwh'></ins><ul id='2uhwh'></ul><sub id='2uhwh'></sub></form><legend id='2uhwh'></legend><bdo id='2uhwh'><pre id='2uhwh'><center id='2uhwh'></center></pre></bdo></b><th id='2uhwh'></th></span></q></dt></tr></i><div id='2uhwh'><tfoot id='2uhwh'></tfoot><dl id='2uhwh'><fieldset id='2uhwh'></fieldset></dl></div>

    <small id='2uhwh'></small><noframes id='2uhwh'>

    1. <tfoot id='2uhwh'></tfoot>

      • <bdo id='2uhwh'></bdo><ul id='2uhwh'></ul>

        我怎样才能得到列“pieces"的总和?在数据表中

        时间:2023-06-05

        1. <small id='cYdJ4'></small><noframes id='cYdJ4'>

            <tbody id='cYdJ4'></tbody>
            <bdo id='cYdJ4'></bdo><ul id='cYdJ4'></ul>
          • <legend id='cYdJ4'><style id='cYdJ4'><dir id='cYdJ4'><q id='cYdJ4'></q></dir></style></legend>
          • <i id='cYdJ4'><tr id='cYdJ4'><dt id='cYdJ4'><q id='cYdJ4'><span id='cYdJ4'><b id='cYdJ4'><form id='cYdJ4'><ins id='cYdJ4'></ins><ul id='cYdJ4'></ul><sub id='cYdJ4'></sub></form><legend id='cYdJ4'></legend><bdo id='cYdJ4'><pre id='cYdJ4'><center id='cYdJ4'></center></pre></bdo></b><th id='cYdJ4'></th></span></q></dt></tr></i><div id='cYdJ4'><tfoot id='cYdJ4'></tfoot><dl id='cYdJ4'><fieldset id='cYdJ4'></fieldset></dl></div>

                  <tfoot id='cYdJ4'></tfoot>
                  本文介绍了我怎样才能得到列“pieces"的总和?在数据表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  如何获得数据表中pieces"列的总和?假设我有下表.如何计算 article="milk" 和 artno="15" 的总"件数?

                  How can I get a sum for the column "pieces" in a datatable? Say I had the following table. How can I calculate the "total" pieces for article="milk" and artno="15"?

                  Columns:   article     artno    pieces
                  Rows:
                  1          milk        15       1
                  2          water       12       1
                  3          apple       13       2
                  4          milk        15       1
                  5          milk        16       1
                  6          bread       11       2
                  7          milk        16       4
                  

                  我的新数据表的结果应该是这样的:

                  The Result of the my new DataTable should be this:

                  Columns:   article     artno    pieces
                  Rows:
                  1          bread       11       2
                  2          water       12       1
                  3          apple       13       2
                  4          milk        15       2
                  5          milk        16       5
                  

                  我的代码:

                  foreach (DataRow foundDataRow in foundRows1)
                  {
                      int i = 0;
                      foreach (DataRow dataRow in foundRows2)
                      {
                          if (object.Equals(dataRow.ItemArray[0], foundDataRow.ItemArray[0])
                              && object.Equals(dataRow.ItemArray[3], foundDataRow.ItemArray[3]))
                          {
                              i = i + Convert.ToInt16(dataRow.ItemArray[4]);
                          }
                      }
                      Debug.Print(i.ToString());
                  }
                  

                  抱歉,我是新的数据库开发人员,我的英语不太好.

                  Sorry, but i'm new DataBase developer and my english speak language is not so good.

                  推荐答案

                  使用 DataTable.Compute 方法,你可以这样做:

                  Using the DataTable.Compute method, you can do:

                  int sum = (int)table.Compute("Sum(pieces)", "article = 'milk' AND artno='15'");
                  

                  这篇关于我怎样才能得到列“pieces"的总和?在数据表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:LINQ 中的聚合与总和性能 下一篇:对二维数组的列求和

                  相关文章

                  最新文章

                  1. <i id='ffRDV'><tr id='ffRDV'><dt id='ffRDV'><q id='ffRDV'><span id='ffRDV'><b id='ffRDV'><form id='ffRDV'><ins id='ffRDV'></ins><ul id='ffRDV'></ul><sub id='ffRDV'></sub></form><legend id='ffRDV'></legend><bdo id='ffRDV'><pre id='ffRDV'><center id='ffRDV'></center></pre></bdo></b><th id='ffRDV'></th></span></q></dt></tr></i><div id='ffRDV'><tfoot id='ffRDV'></tfoot><dl id='ffRDV'><fieldset id='ffRDV'></fieldset></dl></div>
                      <bdo id='ffRDV'></bdo><ul id='ffRDV'></ul>

                    <small id='ffRDV'></small><noframes id='ffRDV'>

                    <legend id='ffRDV'><style id='ffRDV'><dir id='ffRDV'><q id='ffRDV'></q></dir></style></legend>
                    <tfoot id='ffRDV'></tfoot>