Ass 8
Ass 8
ii. Find the number of students whose marks of any subject is available.
SELECT COUNT(*) AS AVAILABLE
FROM STUDENT2103, RESULT2103
WHERE STUDENT2103.ROLLNO = RESULT2103.ROLLNO;
iv.Find the 5th semester student(s) who got maximum marks in a subject.
v.Find the roll number of a student who got maximum marks in CS501.
SELECT ROLLNO, MARKS
FROM RESULT2103
WHERE MARKS = (SELECT MAX(MARKS) FROM RESULT2103 WHERE SUBCODE =
'CS501');
vii.Find the number of students in each department with their department code.
SELECT DEPTCODE, COUNT(*) AS NUMBER_OF_STUDENTS
FROM STUDENT2103
GROUP BY DEPTCODE;
viii.Find the number of students in each department with their department name.
SELECT DEPARTMENT2103.DEPTCODE, COUNT(*) AS NUMBER_OF_STUDENTS,
DEPARTMENT2103.DEPTNAME
FROM STUDENT2103, DEPARTMENT2103
WHERE DEPARTMENT2103.DEPTCODE = STUDENT2103.DEPTCODE
GROUP BY DEPARTMENT2103.DEPTCODE, DEPARTMENT2103.DEPTNAME;
x.Find the student name and roll no who get more than 80 in at least two subject.
SELECT NAME, ROLLNO
FROM STUDENT2103
WHERE (SELECT COUNT(*)
FROM RESULT2103 R
WHERE R.ROLLNO = STUDENT2103.ROLLNO AND R.MARKS > 80) >= 2;
xi.Find the student name and roll no who get more than 70 in average.
SELECT S.NAME, S.ROLLNO
FROM STUDENT2103 S
WHERE (SELECT AVG(MARKS) FROM RESULT2103 R WHERE R.ROLLNO = S.ROLLNO) > 70;
xii.Display number of subject semester wise in dept CSE.
SELECT SEMESTER, COUNT(*)
FROM SUBJECT2103
WHERE DEPTCODE = 'CSE'
GROUP BY SEMESTER;
xv. Find the students name who got highest marks, subjectwise.
SELECT S.SUBJECTNAME, ST.NAME, MAX(R.MARKS) AS HIGHEST_MARKS
FROM SUBJECT2103 S, RESULT2103 R, STUDENT2103 ST
WHERE S.SUBJECTCODE = R.SUBCODE
AND R.ROLLNO = ST.ROLLNO
AND R.MARKS = (SELECT MAX(R2.MARKS) FROM RESULT2103 R2 WHERE R2.SUBCODE =
S.SUBJECTCODE)
GROUP BY S.SUBJECTNAME, ST.NAME;