select customerid, productid,SUM(sellNum) from table1 group by ustomerid, productid having SUM(sellNum) > 10
12 个解决方案
#1
var ary = from t in list group t by new { t.ustomerid, t.productid } into g select new { key = g.Key, source = g};
类似这样
#2
高手,这样ok;不过有遇到其他问题。
最后应用linq的实体是个DataTable,
//DataTable aTable var q = from p in aTable.Select().ToList() group p by new { p[1],p[2]} into g where g.Count()>1 select new { key = g.Key, source = g};
这样写好像有问题
#3
var q = from p in aTable.AsEnumerable()
#4
var query = from s in table1
group s by new { s.customerid, s.productid} into g
where Sum(sellNum) > 10
select new
{
customerid = g.Key.customerid ,
productid = g.Key.productid,
totalNum = g.Sum(s => s.sellNum)
};
var query = from s in table1
group s by new { s.customerid, s.productid} into g
where g.Sum(s => s.sellNum) > 10
select new
{
customerid = g.Key.customerid ,
productid = g.Key.productid,
totalNum = g.Sum(s => s.sellNum)
};
DataTable aTable = new DataTable(); var result = aTable.Rows.Cast<DataRow>().GroupBy(x => x["ustomerid"].ToString() + x["productid"].ToString()).Where(x => { var sum = x.Sum(y => Convert.ToInt32(y["sellNum"])); return sum > 10; });
var ary = from t in list group t by new { t.ustomerid, t.productid } into g select new { key = g.Key, source = g};
类似这样
#2
var ary = from t in list group t by new { t.ustomerid, t.productid } into g select new { key = g.Key, source = g};
类似这样
高手,这样ok;不过有遇到其他问题。
最后应用linq的实体是个DataTable,
//DataTable aTable var q = from p in aTable.Select().ToList() group p by new { p[1],p[2]} into g where g.Count()>1 select new { key = g.Key, source = g};
这样写好像有问题
#3
这样写好像有问题
var q = from p in aTable.AsEnumerable()
#4
var query = from s in table1
group s by new { s.customerid, s.productid} into g
where Sum(sellNum) > 10
select new
{
customerid = g.Key.customerid ,
productid = g.Key.productid,
totalNum = g.Sum(s => s.sellNum)
};
var query = from s in table1
group s by new { s.customerid, s.productid} into g
where g.Sum(s => s.sellNum) > 10
select new
{
customerid = g.Key.customerid ,
productid = g.Key.productid,
totalNum = g.Sum(s => s.sellNum)
};
DataTable aTable = new DataTable(); var result = aTable.Rows.Cast<DataRow>().GroupBy(x => x["ustomerid"].ToString() + x["productid"].ToString()).Where(x => { var sum = x.Sum(y => Convert.ToInt32(y["sellNum"])); return sum > 10; });