【发布时间】:2019-01-25 11:50:10
【问题描述】:
我有一份这种格式的报告
Objectives 表中要传递给报告的列是
ObjectiveID, GoalDescription, Objective, Measure, Expectation, Comment
反对
S/N, Departmental Objective/Initiative, Employee Tasks, Performance Measure,
Performance Expectation, Comments
列。
以下是目标表的数据:
对于工作角色能力部分,列是
CompetenceID, CompetenceAreaDetailsDescription, CompetenceAreaDetailsExpectation
反对
S/N, Behaviours/Skills/Expectation, Expectations
列。
以下是能力表的数据:
Objective 表中的记录总数为 9。它是一对多列,即被评估者可以有多个目标。 Competence 表中的记录总数为 13 条,也是一对多表,即被评估者可以具有多种能力。
两个表中唯一匹配的数据是AppraiseeId。
我的问题:如何创建一个视图来连接这两个表,以便作为报告的数据源。
为了进一步说明,我想显示 Objective 表中的 6 条记录,其中 AppraiseeId = 6 在“目标、任务、度量和目标”部分中,因为它有 6 个目标分配给他并且只显示 3 种能力从能力表的工作角色能力部分分配给他/她。
我已经编写并重写了相当多的查询,但它只会导致许多重复的记录。
CREATE VIEW [dbo].PlanningReport
AS
SELECT
"SpecificObjective"."ObjectiveId" "ObjectiveID",
"SpecificObjective"."AppraiseeId" "AppraiseeID",
"SpecificObjective"."Objective" "Objective",
"SpecificObjective"."Expectation" "Expectation",
"SpecificObjective"."Measure" "Measure",
"SpecificObjective"."Comment" "Comment",
"Competence"."CompetenceAreaDetailsDescription",
"CompetenceAreaDetailsDescription",
"Competence"."CompetenceAreaDetailsExpectation",
"CompetenceAreaDetailsExpectation",
"Competence"."ID" "CompetenceID",
"Competence"."AppraiseeId" "CompetenceAppraiseId",
FROM
"dbo"."SpecificObjective" "SpecificObjective"
LEFT JOIN
"dbo"."Employees" "Appraisee" ON "SpecificObjective"."AppraiseeId" = "Appraisee"."UserId"
INNER JOIN
"dbo"."Competence" "Competence" ON "SpecificObjective".AppraiseeId = "Competence".AppraiseeId
GO
我被困住了。请就该怎么做提出建议。
【问题讨论】:
-
请不要提供数据图片。如果您要提供样本数据,请提供
text,更好的是,还提供CREATE和INSERT语句。
标签: sql sql-server reporting-services rdlc sql-server-data-tools