Professional Documents
Culture Documents
Lab04 De150396
Lab04 De150396
SELECT su.subName
from tblSection se left join tblSubject su
on se.subCode = su.subCode
where se.secYear = 2010
and se.secSemester in (select claCode
from tblStudent
where stuName =
N'Lê Nguyễn Hoài An')
--4.Find the number of students for each class
select claCode, count(claCode) as Total from tblStudent group by claCode
--5.Find all students who passed all courses that he/she has taken in 2010 school year
SELECT stu.*
FROM tblStudent stu, tblReport rp, tblSection sec
WHERE stu.stuCode=rp.stuCode
AND rp.secCode=sec.secCode
AND sec.secYear=2010
EXCEPT
SELECT stu.*
FROM tblStudent stu, tblReport rp, tblSection sec
WHERE stu.stuCode=rp.stuCode
AND rp.secCode=sec.secCode
AND sec.secYear=2010
AND rp.repStatus='R'
--6
--7
SELECT c.subName AS 'Course Name', COUNT(stuCode) AS 'Retake Students'
FROM tblSection a, tblReport b, tblSubject c
WHERE a.secCode = b.secCode
AND a.secYear = 2010
AND b.repStatus = 'R'
AND a.subCode = c.subCode
GROUP BY c.subName