sql 更新最新评估评级TCI

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 更新最新评估评级TCI相关的知识,希望对你有一定的参考价值。

--SELECT * FROM dbo.UserCenterXCenterPguSkill ucxps
--UPDATE dbo.UserCenterXCenterPguSkill
--SET
--    dbo.UserCenterXCenterPguSkill.LatestAssessmentId = NULL,
--    dbo.UserCenterXCenterPguSkill.Rating = null
BEGIN
	DECLARE @assessmentId INT = 0
	DECLARE @rating INT = 0
	DECLARE @tbl TABLE (
		Id INT IDENTITY(1, 1)
		,uccpsId VARCHAR(100)
		)
	DECLARE @uccpsId INT
	DECLARE @I INT = 1
		,@I_RowCount INT

	INSERT INTO @tbl (uccpsId)
	SELECT ucxps.Id
	FROM dbo.UserCenterXCenterPguSkill ucxps

	SET @I_RowCount = @@ROWCOUNT
	SET @I = 1

	WHILE (@I <= @I_RowCount)
	BEGIN
		SELECT @uccpsId = uccpsId
		FROM @tbl
		WHERE Id = @I

		SET @assessmentId = NULL
		SET @rating = NULL

		SELECT TOP 1 @assessmentId = a.AssessmentId
			,@rating = tr.Rating
		FROM dbo.Assessment a
		INNER JOIN dbo.TCIAssessmentResult tr ON a.AssessmentId = tr.AssessmentId
			AND tr.Isactive = 1
		WHERE a.UserCenterXCenterPguSkillId = @uccpsId
		ORDER BY a.CompletedDate DESC

		IF (@assessmentId IS NOT NULL)
		BEGIN
			UPDATE dbo.UserCenterXCenterPguSkill
			SET dbo.UserCenterXCenterPguSkill.LatestAssessmentId = @assessmentId
				,dbo.UserCenterXCenterPguSkill.Rating = @rating
			WHERE dbo.UserCenterXCenterPguSkill.Id = @uccpsId
		END

		SET @I = @I + 1
			--
	END
END
	--

以上是关于sql 更新最新评估评级TCI的主要内容,如果未能解决你的问题,请参考以下文章

sql 报告 - TCI V3报告评级前2波所有技能

sql TCI 114 vw_GetAllWaveRatingReport.sql

sql LMS DB TCI中的链接对象

sql 用评级更新所有评论

浪潮业务稳定连续性获Global Data唯一“Leader”评级 蝉联数据中心整体能力“Very Strong”评级

sql 将员工的评估更新为另一年;将更新常规和NP评估。