0% found this document useful (0 votes)
6 views5 pages

Ass 8

The document contains a series of SQL queries designed to extract various data from a student database. It includes queries to count students in specific departments, find maximum marks, average marks, and identify students based on their performance in subjects. Additionally, it covers faculty counts and department statistics, providing a comprehensive overview of student and faculty data management.

Uploaded by

soumyaadeepdas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views5 pages

Ass 8

The document contains a series of SQL queries designed to extract various data from a student database. It includes queries to count students in specific departments, find maximum marks, average marks, and identify students based on their performance in subjects. Additionally, it covers faculty counts and department statistics, providing a comprehensive overview of student and faculty data management.

Uploaded by

soumyaadeepdas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Assignment 8

i.Find the number of student in CSE second year.


SELECT COUNT(*) AS number_of_students
FROM student2103
WHERE deptcode = 'CSE' AND semester IN ('SEM3', 'SEM4');

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;

iii. Find total number of faculty.


SELECT COUNT(*) AS TOTAL_FACULTY
FROM FACULTY2103;

iv.Find the 5th semester student(s) who got maximum marks in a subject.

SELECT S.NAME, R.MARKS, SU.SUBJECTNAME, SU.SUBJECTCODE


FROM STUDENT2103 S
JOIN RESULT2103 R ON S.ROLLNO = R.ROLLNO
JOIN SUBJECT2103 SU ON R.subcode = SU.SUBJECTCODE
WHERE S.SEMESTER = 'SEM5'
AND R.MARKS = (
SELECT MAX(MARKS)
FROM RESULT2103
WHERE subcode = SU.SUBJECTCODE
);

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');

vi. Display average marks of CS502.


SELECT AVG(MARKS)
FROM RESULT2103
WHERE RESULT2103.SUBCODE = 'CS502';

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;

ix. Find the Department with more than three faculty.


SELECT D.DEPTNAME
FROM DEPARTMENT2103 D
WHERE (SELECT COUNT(TEACHER) FROM SUBJECT2103 S WHERE S.DEPTCODE =
D.DEPTCODE) >= 3;

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;

xiii.Find the department name with maximum number of student.


SELECT DEPTNAME, STUDENTALLOTTED
FROM DEPARTMENT2103
WHERE STUDENTALLOTTED = (SELECT MAX(STUDENTALLOTTED) FROM
DEPARTMENT2103);

xiv.Find the second highest marks of the result table.


SELECT MAX(MARKS) AS SECOND_HIGHEST
FROM RESULT2103
WHERE MARKS NOT IN (SELECT MAX(MARKS) FROM RESULT2103);

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;

You might also like