sql - 交叉连接表以查看一个表中的哪些合作伙伴有另一个表中的报告
问题描述
SX 新手,刚开始深入研究编程世界,可以在这个问题上使用一些帮助。
我需要找出 MentorRelations 表中的哪些合作伙伴组在报告表中没有报告。到目前为止,我只设法交叉加入员工和学员/导师代码,以找出员工的姓名和他们所属的组。(员工代码 = 导师/导师代码)
我在 SQL Server 管理工作室环境中工作。
我正在使用的表格很简短;MentorRelationship [menteecode,relationshipcode,mentorcode]
Employee
[EmployeeID, EmployeeCode, Firstname,lastname]
UserReport
[reportID, employeeID]
Report
[ReportID, name, reportgroupID]
到目前为止,我制定的代码是;
SELECT
m.menteeCode,
E1.firstname AS Mentee_FN,
E1.lastname AS Mentee_LN,
m.mentorCode,
E2.firstname AS Mentor_FN,
E2.lastname AS Mentor_LN,
FROM
MentorRelationshipStaging m
INNER JOIN Employee e1
ON e1.EmployeeCode = m.MenteeCode
INNER JOIN Employee e2
ON e2.EmployeeCode = m.MenteeCode
ORDER BY m.MenteeCode
在此之后我很困惑,非常感谢答案或解决此问题的下一步。我也将继续研究我的目的。
PS我在这里上传了我正在使用的数据库的图表:
https ://m.imgur.com/a/9JMRpFw
解决方案
推荐阅读
- javascript - 如何使用任何 google chrome 扩展在 mat select 中选择一个选项?
- javascript - HERE Maps JS API V3 - 集群:如何获取默认集群图标
- elasticsearch - 如何使用 NEST 包在字段级别创建索引
- excel - 是否有一个公式将相邻单元格带到前 10 个值并处理相同的值?
- eclipse - 哪里可以获得适用于 Mac OS 的 Cross GCC
- python - 开始 Python 彩票功能
- tfs - TFS 无法使用“sqlite3\db.lock”构建,因为它正被另一个进程使用”
- c# - WCF - HTTPS - 传输安全有效,但消息安全在应用程序启动时引发异常
- sql - 从 SQL (server 2012) 中的 Datetime 字段中仅选择“月-日时间”
- python - UnicodeEncodeError for csv paring on apache Beam in python