![](/img/trans.png)
[英]Update values from one column in same table to another in SQL Server
[英]How to count values from one table and update another table on same server in SQL Server?
嘗試這個
;WITH X
AS(
SELECT
EmpId
,COUNT(EntryType) 'P_Count'
FROM
dbo.Attendance
WHERE
EntryType = 'P'
GROUP BY
EmpId
)
UPDATE
P
SET
P.Presents = X.P_Count
FROM
dbo.PayRoll P
INNER JOIN
X A ON A.EmpId = P.EmpId
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.