0% found this document useful (0 votes)
49 views8 pages

IPPracticals SQL 2022-23

The document contains 20 SQL queries related to a student table with columns for student ID, name, class, and marks. The queries perform operations like creating and populating the table, inserting new records, deleting records, updating records, selecting records that meet certain criteria, ordering results, performing aggregate functions, and displaying the table structure.

Uploaded by

Sanjay
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)
49 views8 pages

IPPracticals SQL 2022-23

The document contains 20 SQL queries related to a student table with columns for student ID, name, class, and marks. The queries perform operations like creating and populating the table, inserting new records, deleting records, updating records, selecting records that meet certain criteria, ordering results, performing aggregate functions, and displaying the table structure.

Uploaded by

Sanjay
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/ 8

SQL QUERIES

1
STUDENT TABLE

Write SQL Queries based on the table Student

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. Insert the details of a new student in the above table.


Rollno :6,Name: Gautham ,class: XI,marks:91

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.

13. To update the column doj with the value ‘2010-06-05’.

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.

You might also like