日期:2014-05-20 浏览次数:20797 次
业务编号 币别 金额
A0001 RMB 102.00
A0001 RMB 144.00
A0001 RMB 1030.00
A0002 RMB 231.00
A0002 USD 244.00
A0002 USD 123.00
A0003 RMB 111.00
A0003 USD 222.00
A0003 RMB 333.00
A0003 USD 222.00
想要这样的效果
业务编号 币别 金额
A0001 RMB 102.00
A0001 RMB 144.00
A0001 RMB 103.00
小计 349.00
A0002 RMB 231.00
小计 231.00
A0002 USD 244.00
A0002 USD 123.00
小计 367.00
A0003 RMB 111.00
A0003 RMB 333.00
小计 444.00
A0003 USD 222.00
A0003 USD 222.00
小计 444.00
struct Unit
{
string ID,
string Currency,
float Subtotal
}
class A
{
public List<Business> list{get;set;}
public Unit unit{get;set;}
}
from item in list
group by new{item.ID,item.Currency}
into g
select new A
{
list=new List<Business>(),
unit=new Unit(g.Key.ID,g.Key.Currency,sum(g=>g.Amount))
}
SELECT * FROM (SELECT [业务编号],[币别],SUM([金额]) FROM [Table] GROUP BY [业务编号],[币别]) AS T JION [Table] AS D ON T.[业务编号] = D.[业务编号] AND T.[币别] = D.[币别]
SELECT * FROM (SELECT [业务编号],[币别],SUM([金额]) FROM [Table] GROUP BY [业务编号],[币别]) AS T JOIN [Table] AS D ON T.[业务编号] = D.[业务编号] AND T.[币别] = D.[币别]