select CandidateName, SUM(Amount) as Amount
from MaseHisab
where Member = 'ABC+DEF+GHI'
group by CandidateName
CandidateName Amount
jain 72.00
rakesh 30.00
shams 110.00
答案 0 :(得分:1)
如果您正在使用SQL-Server
使用with rollup
。这将为您提供
select isnull(CandidateName,'Total'),SUM(Amount) as Amount
from MaseHisab
where Member='ABC+DEF+GHI' group by CandidateName
with rollup
O / P
CandidateName Amount
jain 72.00
rakesh 30.00
shams 110.00
NULL 212.00
修改强>
使用isnull
。见上面的查询
isnull(CandidateName,'Total')
如果您正在使用其他数据库
COALESCE(CandidateName,'Total')