MySQL Solutions for Class 12 Students
MySQL Solutions for Class 12 Students
The SQL command to calculate the average marks of students is SELECT AVG(Marks) FROM Students;. The expected result should be 87.0000 .
Deleting Riya's record with RollNo=2 would require using the SQL command DELETE FROM Students WHERE RollNo=2;. This would reduce the number of records in the 'Students' table and potentially alter aggregate calculations like average marks or rankings .
To insert multiple student records, use the SQL command INSERT INTO Students VALUES (...). For example, to insert records for five students, you combine them into one command: INSERT INTO Students VALUES (1,'Amit',90),(2,'Riya',85),(3,'Karan',70),(4,'Suman',88),(5,'Pooja',95);. This batch processing maximizes efficiency and should result in Query OK, 5 rows affected .
To retrieve the names of students scoring more than 80, use the SQL command SELECT Name FROM Students WHERE Marks > 80;. The expected result includes four students: Amit, Riya, Suman, and Pooja .
The SQL command to display all records from the 'Students' table is SELECT * FROM Students;. The expected output should be a table listing all students: RollNo | Name | Marks with each student's data on a new line .
To create a database named 'School', you can use the SQL command CREATE DATABASE School; and the expected outcome would be: Query OK, 1 row affected (0.01 sec).
To determine both the maximum and minimum marks, use SELECT MAX(Marks), MIN(Marks) FROM Students;. The expected outcome is a single row displaying maximum marks as 95 and minimum as 70 .
Updating Karan's marks to 75 requires the SQL statement UPDATE Students SET Marks=75 WHERE Name='Karan';. This operation changes Karan's marks from 70 to 75, impacting average calculations and relative standing among peers .
Use the SQL command SELECT * FROM Students ORDER BY Marks DESC; to sort students by marks in descending order. The output should list students starting with the highest scorer, Pooja, and continue to the lowest, Karan .
Omitting a primary key when creating a table can lead to duplicate records, compromising data integrity. It also complicates record retrieval and updates, as there are no unique identifiers to optimize query performance or ensure entity integrity, potentially causing database anomalies .