0% found this document useful (0 votes)
11 views2 pages

Mysql Prctical1

Uploaded by

hem
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)
11 views2 pages

Mysql Prctical1

Uploaded by

hem
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/ 2

MYSQL PRACTICAL ---1

Q1. Create a table named STUDENTS with specified columns and data types.

CREATE TABLE STUDENTS (


RollNo INT PRIMARY KEY,
Name VARCHAR(50),
Class CHAR(2),
Marks INT
);

Q2. Insert 5 records into the STUDENTS table.

INSERT INTO STUDENTS (RollNo, Name, Class, Marks)


VALUES
(1, 'Alice', '12', 90),
(2, 'Bob', '11', 85),
(3, 'Charlie', '12', 75),
(4, 'David', '11', 92),
(5, 'Emily', '12', 88);

Q3. Display all records from the STUDENTS table.

SELECT * FROM STUDENTS;

Q4. Display the names and marks of students in class 12.

SELECT Name, Marks FROM STUDENTS WHERE Class = '12';

Q5. Find the average marks of all students.

SELECT AVG(Marks) FROM STUDENTS;

Q6. Count the number of students in each class.

SELECT Class, COUNT(*) FROM STUDENTS GROUP BY Class;

Q7. Find the highest marks obtained by any student.

SELECT MAX(Marks) FROM STUDENTS;

Q8. Update the marks of student with RollNo 2 to 95.

UPDATE STUDENTS SET Marks = 95 WHERE RollNo = 2;

Q9. Delete the record of the student with RollNo 3.

DELETE FROM STUDENTS WHERE RollNo = 3;

Q10. Display student details in ascending order of their names.


SELECT * FROM STUDENTS ORDER BY Name ASC;

Q11. Display the top 3 scorers.

SELECT * FROM STUDENTS ORDER BY Marks DESC LIMIT 3;

Q12. Find the students whose marks are between 80 and 90.

SELECT * FROM STUDENTS WHERE Marks BETWEEN 80 AND 90;

Q13. Display the names of students starting with 'A'.

SELECT Name FROM STUDENTS WHERE Name LIKE 'A%';

Q14. Find the students who have a specific subject (assuming a new column 'Subject')

SELECT * FROM STUDENTS WHERE Subject = 'Physics';

Q15. Calculate the total marks obtained by each student (assuming a new column 'Total')

SELECT Name, SUM(Total) FROM STUDENTS GROUP BY Name;

You might also like