我有一张记录表
create table rstbljobs
(
AutoID identity(1,1),
AssignedToRstEmpID int,
priorityid int,
Jobstatusid int
)
Insert into rstbljobs values ( 147,202,374)
Insert into rstbljobs values ( 169,214,374)
Insert into rstbljobs values ( 170,202,374)
Insert into rstbljobs values ( 176,202,374)
Insert into rstbljobs values ( 182,202,374)
Insert into rstbljobs values ( 147,214,374)
Insert into rstbljobs values ( 183,202,374)
Insert into rstbljobs values ( 170,214,374)
Insert into rstbljobs values ( 182,214,374)
Insert into rstbljobs values ( 170,202,374)
Insert into rstbljobs values ( 147,214,374)
Insert into rstbljobs values ( 147,202,374)
Insert into rstbljobs values ( 169,202,374)
Insert into rstbljobs values ( 169,214,374)
我有另一张桌子 UsersRSDesk
Create table UsersRSDesk
(
userid int,
IsRecruit bit,
status bit,
noofhighprtjobs varchar(50)
)
记录是
insert into UsersRSDesk values (147,1,0,null)
insert into UsersRSDesk values (169,1,0,null)
insert into UsersRSDesk values (170,1,0,null)
insert into UsersRSDesk values (176,1,0,null)
insert into UsersRSDesk values (182,1,0,null)
insert into UsersRSDesk values (183,1,0,null)
查询如下:
select AssignedToRstEmpID,COUNT(AssignedToRstEmpID)as Noofcount from RStblJobs
group by AssignedToRstEmpID
从上面的查询中,我希望将来自 rstbljobs 的 noofcount 插入 usersrsdesk.noofhighprtjobs 列。每当我更新 rstbljobs 表时,这里也应该反映相同的计数。