datatable表结构如下
gid f1 f2 f3 ....
1   时间类型......
按gid分组,如果f1为空就计为0,否则计为1,然后求和,用才count函数吧

解决方案 »

  1.   

     DataTable dt = new DataTable();
                 var ary = from t in dt.AsEnumerable()
                           group t by t.Field<int>("gid") into g
                           select new { g.Key, count = g.Sum(tt => tt.Field<string>("f1").Trim() == "" ? 0 : 1) };
                
      

  2.   

      var ary = from t in dt.AsEnumerable()
                           group t by t.Field<int>("gid") into g
                           select new { g.Key, f1count = g.Count(tt => tt.Field<string>("f1")) };这样行不行