我有一个看起来像这样的结果集。我想合计支付的金额并将 DTV TOW 和 FlatBED 合并为 1 行。有什么办法可以完成吗?
CaseServiceID PurchaseOrderID PaidAmount DTV TOW FLATBED
227 15000227 19.20 1 0
227 15000227 45.00 0 1
注意:DTV TOW
和FLATBED
列来自透视表
编辑
枢轴看起来像这样:
select
*
from
(
select
cla.CaseServiceID
,cla.ServiceTypeProgKey
,cla.ClaimAmount
,cla.PaidAmount
,cla.ClaimQuantity
from
Claim cla
) as srcServiceType
pivot
(
max(ServiceTypeProgKey) for ServiceTypeProgKey in ([FLATBED],[DTV TOW]
) as pvtServiceType