因为派生表 'm' 包含聚合,或 DISTINCT 或 GROUP BY 子句,或 PIVOT 或 UNPIVOT 运算符,所以不可更新

1.因为派生表 'm' 包含聚合,或 DISTINCT 或 GROUP BY 子句,或 PIVOT 或 UNPIVOT 运算符,所以不可更新

哪位大神帮忙下
sql语句如下:
update m set m.FEntrySelfB0168 = rn.FPrice, m.FEntrySelfB0169 = rn.FPrice * m.fQty
from (
select n.FDetailID,MAX(rn.FDetailID) FRKDetailID,m.FDate,n.FEntrySelfB0168,n.FEntrySelfB0169,n.FQty
from ICStockBill m
left join ICStockBillEntry n on m.FInterID=n.FInterID
left join ICStockBillEntry rn on n.FItemID =rn.FItemID --产品入库明细
join ICStockBill r on rn.FInterID=r.FInterID and r.FTranType=2 and m.FDate >=r.FDate --产品入库表头
where m.FTranType=21
group by n.FDetailID,m.FDate,n.FEntrySelfB0168,n.FEntrySelfB0169,n.FQty
) m left join ICStockBillEntry rn on m.FRKDetailID=rn.FDetailID
where rn.FPrice <>0 and (isnull(rn.FPrice,0)<>isnull(m.FEntrySelfB0168,0)
or isnull(m.FEntrySelfB0169,0)<>m.fqty* isnull(m.FEntrySelfB0168,0))
and CONVERT(varchar(10), m.FDate, 120) >= '2020-06'
and CONVERT(varchar(10), m.FDate, 120) >= '2020-07-01'
and CONVERT(varchar(10), m.FDate, 120) <= '2020-07-04'

https://blog.csdn.net/qq_39578195/article/details/78963419

你要搞清楚:“update m set m.FEntrySelfB0168 = rn.FPrice, m.FEntrySelfB0169 = rn.FPrice * m.fQty”的m是不是真实的一个表,估计你是想更新ICStockBill表,因为括号里有个“ICStockBill m”,外面更新的那个m不是里面的那个m,外面的m是派生表(虚拟的),里面的m才是真实的表