我有表结构
montantPayeProperty.set(montantPaye);
我必须通过Deal,AC NO分组并且还必须报告其他列,但是对于Int数量必须为两个prod类型进行总和。
我该如何实现呢?
结果
ACNo Deal PRODTYPE INT AMT
100 123 OS 23
100 123 EX 7
答案 0 :(得分:1)
这样的事情?
select ACNo,
Deal,
sum([INT AMT]) as [Total INT]
from unknowntablename
group by ACNo, Deal
你可以这样测试:
declare @table table (ACNo int, Deal int, PRODTYPE varchar(2), [INT AMT] int)
insert into @table values (100, 123, 'OS', 23)
insert into @table values (100, 123, 'EX', 7)
select ACNo,
Deal,
sum([INT AMT]) as [Total INT]
from @table
group by ACNo, Deal
结果将是:
ACNo Deal Total INT
100 123 30
答案 1 :(得分:1)
试试这个
SELECT AccNo, DEAL, SUM([INT AMT]) AS Total Amount
FROM Table
GROUP BY AccNo, DEAL