new dbms practical
new dbms practical
answer the given (sample) queries using the standalone SQL editor.
CREATE TABLE STUDENTS( ROLLNO CHAR(6) PRIMARY KEY, STUDENTNAME VARCHAR(25), COURSE
VARCHAR(15), DOB DATE );
ROLLNO CHAR(6),
SID CHAR(6),
DATEOFENROLLMENT DATE,
);
INSERT INTO ENROLLMENTS (ROLLNO, SID, DATEOFENROLLMENT)
VALUES
SELECT STUDENTNAME
FROM STUDENTS
5. Retrieve students' names whose roll no either starts with 'X' or 'Z' and ends with '9'
SELECT STUDENTNAME
FROM STUDENTS
6. Find society details with more than N TotalSeats where N is to be input by the user
SELECT *
FROM SOCIETIES
UPDATE SOCIETIES
8. Find society names in which more than five students have enrolled
SELECT S.SOCNAME
FROM SOCIETIES S
GROUP BY S.SOCNAME
SELECT ST.STUDENTNAME
FROM STUDENTS ST
LIMIT 1;
10. Find the name of the most popular society (on the basis of enrolled students)
SELECT SOCIETIES.SOCNAME
FROM SOCIETIES
GROUP BY SOCIETIES.SOCID
LIMIT 1;
11. Find the name of two least popular societies (on the basis of enrolled students
SELECT SOCIETIES.SOCNAME
FROM SOCIETIES
GROUP BY SOCIETIES.SOCID
LIMIT 2;
12. Find the students names who are not enrolled in any society.
SELECT STUDENTNAME
FROM STUDENTS
SELECT STUDENTNAME
FROM (
FROM STUDENTS S
GROUP BY S.STUDENTNAME
SELECT SOCIETIES.SOCNAME
FROM SOCIETIES
GROUP BY SOCIETIES.SOCID
LIMIT 1;
15. Find names of all students who have enrolled in any society and society names in which
FROM STUDENTS ST
SELECT STUDENTNAME
FROM STUDENTS
17. Find society names such that its mentor has a name with 'Gupta' in it.
SELECT SOCIETIES.SOCNAME,MENTORNAME
FROM SOCIETIES
18. Find the society names in which the number of enrolled students is only 10% of its
capacity.
SELECT SOCIETIES.SOCNAME
FROM SOCIETIES
GROUP BY SOCIETIES.SOCID,SOCIETIES.TOTALSEATS
FROM SOCIETIES
GROUP BY SOCIETIES.SOCID;
UPDATE SOCIETIES
21. Add the enrollment fees paid ('yes'/'No') field in the enrollment table.
UPDATE ENROLLMENTS
UPDATE ENROLLMENTS
UPDATE ENROLLMENTS
FROM SOCIETIES
GROUP BY SOCIETIES.SOCNAME;
SELECT STUDENTS.STUDENTNAME
FROM STUDENTS
GROUP BY STUDENTS.ROLLNO
25. Count the number of societies with more than 4 students enrolled in it
FROM ENROLLMENTS E
GROUP BY E.SID
FROM STUDENTS
28. Find names of students who were born in 2001 and are enrolled in at least one society.
FROM STUDENTS
29. Count all societies whose name starts with 'S' and ends with 't' and at least 5 students are
enrolled in the society.
GROUP BY SOC.SOCNAME
Society name Mentor name Total Capacity Total Enrolled Unfilled Seats
SELECT