exec pt_callnoseelist 'tangzj'
--某个人的未阅
select * from CallNoSee where userid='yangss' and delflag='0' and calltag='0'
--某个人的保留
select * from CallNoSee where userid='yangss' and delflag='0' and calltag='1'
--未阅>1000条的账号姓名清单 45行
select b.DeptName,a.de,a.username,a.n from Department b
inner join
(select count(*) as N,a.userid,d.DeptParentID,b.UserName,d.DeptName as de from callNosee a
inner join users b
on a.userid=b.UserID
inner join RelationshipUsers c
on b.userid=c.UserID
inner join Department d
on c.DeptID=d.DeptID
where a.DelFlag=0 and a.CallTag=0 and c.RelaPrimary=1
group by a.userid,b.UserName,d.DeptName,d.DeptParentID
having count(*)>1000
) a
on a.DeptParentID=b.DeptID
order by n desc
--更新为已阅:
update CallNoSee set delflag='0' where userid='yangss' and delflag='0' and calltag='0'