Student
_______________________
SudentId Name
101 Peter
103 John
112 James
116 Peter
117 Peter
SudentId_Subject
_______________________
SudentId Subject
101 Physics
103 Chemistry
112 Mathematics
116 Physics
117 Commerce
要查找重複的學生社團一個表中刪除重複的,我想查詢從具有與另一個表
select * from Student group by Name having count(*)>1
,得到
SudentId Name
_______________________
101 Peter
116 Peter
117 Peter
其實我需要具有相同主題的過濾學生。即,
101 Peter
116 Peter
是重複的(同一主體),但不117 Peter
我如何寫這個查詢?
Sometnihg是這樣的嗎? 'select count(a.StudentId),來自Student a的a.Name,SudentId_Subject b其中b.EmpId = a.StudentId group by a.Name,b.Department'。你確定沒有兩個Peters在同一個部門工作嗎? – Nomeaning25