我有3张桌子
Reportingspeciality
ID Speciality HospitalName
1 Neurology Sun
2 Emergency Jefferson
5 Pulmonary Mary
5 Anesthesiology Mayo
PhysicianJMGreportiongspeciality
ID JMGReportingSpeciality 11医师助理 17麻醉学 21麻醉学
PhysicianName
FirstName LastName ID
Sam ABC 5
Joseph DEF 2
Sam ABC 5
Jackson DEF 1
想要输出
FirstName LastName ID Hospital Specialty
Sam ABC 5 Mary Pulmonary
Sam ABC 5 Mayo Anesthesiology
也按ID和医院分组 麻醉学是表格中的不良数据,我必须在结果中获得。
答案 0 :(得分:2)
显而易见的查询有什么问题?
SELECT
FirstName,
LastName,
PhysicianName.ID,
HospitalName
FROM
PhysicianName
INNER JOIN
Reportingspecialty
ON
PhysicianName.ID = Reportingspecialty.ID
GROUP BY
PhysicianName.ID, HospitalName
为什么名称表中有两个完全相同的行?