select AssignedToUserName as [待办人],ProblemCode as [事务编码],Title as [事务],'<a href="../pts/viewproblem.aspx?problem=' + cast(ProblemID as nvarchar) + '" target=_blank>链接</a>' as [链接]
FROM v_Pts_Problems
where AssignedTo in (SELECT UserID FROM Accounts_Users WHERE DeptID=部门ID)
order by AssignedToUserName
-- 部门ID可以从Accounts_Department表中查询