篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql Master Select At Manager Level相关的知识,希望对你有一定的参考价值。
DECLARE @mgrUserId int = 13006
DECLARE @waveId int = 103
DECLARE @assessmentId int = -1
--Manager
SELECT u.FacilityDesc,u.* FROM dbo.[User] u WHERE u.UserId = @mgrUserId
-- Active Reportees
SELECT * FROM dbo.[User] u WHERE u.InternalManagerId = @mgrUserId AND u.IsActive = 1
--Assessments under manager
SELECT a.AssessmentId,a.AssessmentName, a.UserCenterXCenterPguSkillId, a.WaveId,w.Name AS WaveName, a.TestTakenCount, a.NoOfRetest, a.AssessmentStatusId,asm.NAME AS AssessmentStatus, a.StartDate, a.CompletedDate, a.CreatedDate, a.CreatedBy, a.ReassignedDate, a.ReassignedBy FROM dbo.Assessment a
INNER JOIN dbo.UserCenterXCenterPguSkill uccps ON a.UserCenterXCenterPguSkillId = uccps.Id
INNER JOIN dbo.UserXCenter ux ON uccps.UserXCenterId = ux.UserXCenterId
INNER JOIN dbo.[User] u ON ux.UserId = u.UserId AND u.InternalManagerId = @mgrUserId
LEFT JOIN dbo.CenterXPGUXSkill cps ON uccps.CenterXPGUXSkillId = cps.CenterXPGUXSkillId
LEFT JOIN dbo.CenterXPGU cx ON cps.CenterXPGUId = cx.CenterXPGUId
LEFT JOIN dbo.PGU p ON cx.PGUId = p.PGUId
LEFT JOIN dbo.Skill s ON cps.SkillId = s.SkillId
LEFT JOIN dbo.Wave w ON a.WaveId = w.Id
LEFT JOIN dbo.AssessmentStatusMaster asm ON a.AssessmentStatusId = asm.Id
WHERE (@waveId = -1 OR a.WaveId = @waveId)
以上是关于sql Master Select At Manager Level的主要内容,如果未能解决你的问题,请参考以下文章