I have 2 tables in SQL Professors (TeacherID, TeacherName, Salary,DeptID) and Co
ID: 3624017 • Letter: I
Question
I have 2 tables in SQL Professors (TeacherID, TeacherName, Salary,DeptID) and Courses (CourseID, CourseName, TeacherID) the question is List the department with the most number of teachers. When I put this statement I get a list of all the course id and department idProfessors
TeacherID TeacherName Salary DeptID
11 Raghavan 66000 01
12 Hackbarth 65000 01
13 Frank Braun 67000 01
14 John Maddoc 58000 02
15 Raghavan 68000 03
Courses
CourseID CourseName TeacherID
INF282 Database 11
MBI677 ABAP 11
MBI650 Project Management 12
MBI665 Knowledge Management 13
BUS610 Law & Public Policy 14
BUS330 Ethics 14
INF382 IT Security 13
INF480 Systems Analysis 12
INF420 Web Development 15
how would i do this? thanks!
Explanation / Answer
Dear user, The query is : select C.CourseID, P.DeptID from Professors P inner join Courses C on P.TeacherID = C.TeacherID and P.DeptID in ( select DeptID from professors group by (DeptID) having Count(DeptID) = (select top 1 Count(DeptID) from professors group by (DeptID) order by DeptID) )
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.