sql Master Select At Manager Level

Posted

tags:

篇首语:本文由小常识网(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的主要内容,如果未能解决你的问题,请参考以下文章

Microsoft C++ exception: SqlException at memory location

T-SQL All-At-Once 操作解析

OUTPUT INSERTED Id/SCOPE_IDENTITY() 在 C# (ASP.NET Core Razor Pages) SQL 查询中返回 null,在 SQL Server Mana

nativescript 保存 blob 错误无法将对象转换为 [B at index 1

ORA-06502:PL/SQL:数字或值错误:NULL 索引表键值 ORA-06512:在“OJC.JC_MASTER”,第 129 行

MySQL设计规范