IPPracticals SQL 2022-23
IPPracticals SQL 2022-23
1
STUDENT TABLE
1.Create the following table student with the student id, name, class and marks as attributes
where the student id is the primary key. Populate the table with 5 rows.
Ans:
create table student(studentid int primary key, name varchar(20),class char(4),marks
decimal(4,2));
insert into student values(1,'Aman','XII',75);
insert into student values(2,'Vijay','XII',80);
insert into student values(3,'Amruth','XI',89);
insert into student values(4,'Smriti','XI',93);
insert into student values(5,'Bhavya','XI',67);
2
3. Delete the details of a student having student id 6 from the above table.
4. Use the select command to get the details of the students with marks more than 80.
5. Find the minimum and maximum of the marks in a student marks table.
6. Write a SQL query to order the (student ID, marks) table in descending order of the marks.
3
7. To find the sum and average of marks of all students in class XI.
8. Find the total number of students from each class in the table using group by.
9. To display the total no of students and class, if there are more than 2 students in the class.
4
10. To display the names of students having more than 3 letters in their names.
11. To concatenate and display name and marks of students having marks less than 80 .
12. To add a new column named doj with data type date.
5
14. To display the name of the month on which Aman joined the school.
15. To display the class of those students in lowercase whose name starts with the letter ‘A’ .
16.To display the 2 letters of the student’s name from the 3rd position onwards of those
students having marks between 70 and 80.
6
17. To display name and class of those students not having the letter ‘r’ anywhere in their
names using instr().
18. To display 2 letters from right of the student names having secured marks either 70 or 80.
19. To find the reminder of the division of the marks of the class XII students by 2.
7
20. To show the structure of the table student.