Hello All,
This is another query I have to solve using SQL
Assume the following:
Transcript( stdid , crscode, Sem, Grade)
Teaching(Profid, crscode, Sem)
Professor( Id, ProfName, Dept)
The query is : find all student ids who had taken a course from each professor in the 'MAT' department
This is My attempt to solve the query :
SELECT DISTINCT T.stdid
FROM Transcript T, Professor P, Teaching Teach
WHERE Teach.profid = P.id AND P.Dept = 'MAT' AND
Teach.crscode = T.crscode
Am I so far right ?Hi
Here How I trace the answer :
1. All 'MUS' professors : MUSPROF = id ( deptid= 'MUS' Professor)
2. JOIN with Teaching to obtain which course taught by whom
PROFCRS = (Teaching (JOIN profid=id) MUSPROF)
3. STDCRS = (Transcript (JOIN crscode = crscode) PROFCRS)
4. stdid, crscode (STDCRS).
where :
= project
= select
??
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment