关于字段多值拼接,STRING_AGG,FOR XML PATH 返回
LEFT JOIN (
SELECT
STRING_AGG(A.ReceMoneyYwh, ',') AS ReceMoneyYwh, A.CostItemId
FROM
(
SELECT
ReceMoneyItem.Id,
ReceMoneyItem.CostItemId,
ReceMoney.CurDate AS CurDate,
Pzhk.Pzh AS ReceMoneyYwh ,
[ReceMoney].[DocNo] AS [DocNo],
[ReceMoney].[ActName] AS [ActName]
FROM
ReceMoneyItem
LEFT JOIN ReceMoney ON ReceMoney.Id= ReceMoneyItem.ReceId
LEFT JOIN Pzhk ON Pzhk.Ywh= ReceMoney.Ywh
) AS A GROUP BY A.CostItemId
) AS Rece ON Rece.CostItemId = Costitem.Id
好像没有上面这种查询拼接的支持,看文档上支持的是下面,字段是个子查询。
热忱回答(1)
-
fate sta VIP01个月前
在结合嵌套查询就行了
0 回复