using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace ConsoleApplication2
{
public class Plan
{
public string ProjectInfoId
{
get;
set;
} public string CommandInfoId
{
get;
set;
} public int value
{
get;
set;
}
} class Program
{
static void Main(string[] args)
{
List<Plan> listPlan = new List<Plan>() {
new Plan{ProjectInfoId="", CommandInfoId="", value=},
new Plan{ProjectInfoId="", CommandInfoId="", value=},
new Plan{ProjectInfoId="", CommandInfoId="", value=},
new Plan{ProjectInfoId="", CommandInfoId="", value=},
new Plan{ProjectInfoId="", CommandInfoId="", value=},
new Plan{ProjectInfoId="", CommandInfoId="", value=},
}; var PlanGroups =
from p in listPlan
group p by
new
{
p.ProjectInfoId,
p.CommandInfoId }
into g
let condition = g.Sum<Plan>(t => t.value)
where condition >
select new
{
g.Key,
NumProducts = condition
}; foreach (var group in PlanGroups)
{
Console.WriteLine(string.Format("{0},{1}:{2}", group.Key.ProjectInfoId.ToString(), group.Key.CommandInfoId.ToString(), group.NumProducts));
}
}
}
}

Linq-分组统计的更多相关文章

  1. Linq to SQL 语法查询(链接查询,子查询 & in操作 & join,分组统计等)

    Linq to SQL 语法查询(链接查询,子查询 & in操作 & join,分组统计等) 子查询 描述:查询订单数超过5的顾客信息 查询句法: var 子查询 = from c i ...

  2. 每日学习心得:CustomValidator验证控件验证用户输入的字符长度、Linq 多字段分组统计、ASP.NET后台弹出confirm对话框,然后点击确定,执行一段代码

    2013-9-15 1.    CustomValidator验证控件验证用户输入的字符长度 在实际的开发中通常会遇到验证用户输入的字符长度的问题,通常的情况下,可以写一个js的脚本或者函数,在ASP ...

  3. C# Linq及Lamda表达式实战应用之 GroupBy 分组统计

    在项目中做统计图表的时候,需要对查询出来的列表数据进行分组统计,首先想到的是避免频繁去操作数据库可以使用 Linq eg: //例如对列表中的Cu元素进行按年GroupBy分组统计 //包含年份,平均 ...

  4. DataTable、List使用groupby进行分组和分组统计;List、DataTable查询筛选方法

    DataTable分组统计: .用两层循环计算,前提条件是数据已经按分组的列排好序的. DataTable dt = new DataTable(); dt.Columns.AddRange(new ...

  5. Linq分组功能

    Linq在集合操作上很方便,很多语法都借鉴自sql,但linq的分组却与sql有一定的区别,故整理发布如下. 1.  Linq分组 分组后以Key属性访问分组键值. 每一组为一个IEnumberAbl ...

  6. 【.Net】 大文件可使用的文本分组统计工具(附带源码,原创)

    本工具可实现的效果: 1.读取大文件(大于1GB) 2.根据分隔符分割后的列分组 3.速度快. 4.处理过程中,可以随时停止处理,操作不卡死. 5.有对当前内存的实时监测,避免过多占用内存,影响系统运 ...

  7. Dev用于界面按选中列进行分组统计数据源(实用技巧)

    如果有用U8的可以明白这个功能就是模仿他的统计功能.我不过是把他造成通用的与适应于DEV的. (效率为6000条数据分组统计时间为3秒左右分组列过多5秒.1000条以下0.几秒,500条下0.00几秒 ...

  8. ORACLE的分组统计之ROLLUP(一)

    Oracle 9i以后,扩展了group by 的功能,能够满足大部分多维数据的分析统计功能,主要表现: 1. rollup,cube,grouping sets 扩展group by字句提供了丰富的 ...

  9. XtraGrid使用心得(折叠式主细档、分组统计)

    XtraGrid的关键类就是:GridControl和GridView.GridControl本身不显示数据,数据都是显示在GridView/CardView/XXXXView中.GridContro ...

  10. Oracle按不同时间分组统计

    Oracle按不同时间分组统计 Oracle按不同时间分组统计的sql 如下表table1: 日期(exportDate) 数量(amount) -------------- ----------- ...

随机推荐

  1. miniui中常用的状态显示方式

    1.查询sys_code表得到对应的状态 考生状态:<input class="mini-combobox" style="" textField=&qu ...

  2. Codeforces Round #381 (Div. 2) 复习倍增//

    刷了这套题  感触良多 我想 感觉上的差一点就是差很多吧 . 每次都差一点  就是差很多了... 不能气馁..要更加努力去填补那一点点.  老天不是在造物弄人,而是希望你用更好的自己去迎接自己. A. ...

  3. 字节b换算kb/mb/gb/tb/pb

    public static string HumanReadableFilesize(double size) { string[] units = new string[] { "B&qu ...

  4. 小程序de 一些经验1

    尝试着写微信的小程序,一个简单的表单验证.一开始就花了大把的时间尝试如何开始小程序的准备工作. 鼓捣半天,AppId是没有的,于是用了不用appId的模拟版.其实只要下载一个小程序版的微信开发工具. ...

  5. JS 获取浏览器和屏幕宽高信息

    网页可见区域宽:document.body.clientWidth网页可见区域高:document.body.clientHeight网页可见区域宽:document.body.offsetWidth ...

  6. 【随笔】从gitHub上获取源码

    有时候,需要从gitHub上获取源码,下面介绍几个方法: 1.获取链接: 打开gitHub代码库的页面,能在右边看到这个: 点击红圈里的标记,该链接就会复制下来. 然后,如果安装了小乌龟(Tortoi ...

  7. js函数和运算符

    函数是由事件驱动或者它被调用时执行可重复使用的代码块. <script> function myFunction(){ Alert(“hello World!”): } </scri ...

  8. Only the sqlmigrate and sqlflush commands can be used when an app has migrations.

    samcao@samcao-Lenovo-IdeaPad-Y470:~/caodjango/caossh$ python manage.py sqlall getssh System check id ...

  9. Android之GridView

    <GridView android:id="@+id/gridView" android:layout_width="match_parent" andr ...

  10. 解决root用户ssh配置无密码登陆/hadoop用户照仿可以实现相同功能:hadoop用户登录并且把命令的所有root换成home/hadoop

    http://inuyasha1027.blog.51cto.com/4003695/1132896/ 主机ip:192.168.163.100(hostname: node0) ssh无密码登陆的远 ...