0% found this document useful (0 votes)
7 views1 page

MySQL Practice Set for Class 12 Students

The document is a practice set for Class 12 students focusing on SQL coding questions. It includes tasks such as creating and manipulating a Students table, inserting records, displaying filtered results, updating and deleting records, and performing joins with another Subjects table. The practice set emphasizes proper SQL syntax and clean code formatting.
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)
7 views1 page

MySQL Practice Set for Class 12 Students

The document is a practice set for Class 12 students focusing on SQL coding questions. It includes tasks such as creating and manipulating a Students table, inserting records, displaying filtered results, updating and deleting records, and performing joins with another Subjects table. The practice set emphasizes proper SQL syntax and clean code formatting.
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

Class 12 - MySQL Practice Set (Coding Questions)

■ Instructions: Answer the following SQL coding questions. Each question carries equal marks.
Use proper SQL syntax and write clean, indented code.

1. Create a table named Students with fields: RollNo (INT), Name (VARCHAR(30)), Class (INT),
Marks (INT).

2. Insert five records into the Students table with sample data.

3. Display all student records whose marks are greater than 75.

4. Display the names of students sorted in alphabetical order.

5. Update the marks of a student with RollNo = 102 to 90.

6. Delete records of students who have marks less than 40.

7. Display the total number of students in each class using the GROUP BY clause.

8. Find the highest and lowest marks in the Students table.

9. Create another table named Subjects with fields: SubjectCode (INT), SubjectName
(VARCHAR(30)), RollNo (INT). Then display student names with their subject names using an
INNER JOIN.

10. Display the name and marks of the top three scoring students using ORDER BY and LIMIT.

End of Practice Set

Common questions

Powered by AI

To list all student names in alphabetical order, you use the SQL query: SELECT Name FROM Students ORDER BY Name ASC.

The approach in SQL to select the top three students by marks involves using ORDER BY Marks DESC and LIMIT 3: SELECT Name, Marks FROM Students ORDER BY Marks DESC LIMIT 3. This is relevant in data analysis for identifying top performers, enabling targeted interventions and rewarding academic excellence.

The GROUP BY clause in SQL is significant for aggregating data into summary rows, typically used with aggregate functions like COUNT. In the context of displaying the total number of students per class, it allows grouping of records by the 'Class' field and calculating the count of students within each class.

The 'Subjects' table complements the 'Students' table by allowing the association of subjects with student records through the RollNo field. This design, exemplified by the common RollNo field, supports normalization by separating related data into multiple tables, reducing redundancy and inconsistencies, and facilitating efficient data retrieval through JOIN operations.

Using SQL's ORDER BY clause for data presentation, such as ordering student names or marks, directly impacts how data is organized and perceived. It improves readability, allowing clear insights like ranking or grouping. However, it also introduces complexity in query execution and may affect performance with large datasets, necessitating indexing or query optimization strategies.

You can create a table named 'Students' using the SQL command: CREATE TABLE Students (RollNo INT, Name VARCHAR(30), Class INT, Marks INT)

SQL can delete records using the query: DELETE FROM Students WHERE Marks < 40. This operation is necessary for data management, ensuring that only relevant and meaningful records are retained in the database. It helps maintain data integrity by removing poorly performing entries and potentially facilitating performance optimization by reducing table size.

You can find the highest and lowest marks using the SQL query: SELECT MAX(Marks) AS Highest, MIN(Marks) AS Lowest FROM Students. This uses aggregate functions MAX and MIN to determine the highest and lowest values, respectively.

To update a student's marks in SQL where the RollNo is 102, you use the query: UPDATE Students SET Marks = 90 WHERE RollNo = 102. This changes the marks field for the student with the specified RollNo.

An INNER JOIN in SQL combines rows from two tables based on a related column, returning only matching rows from both tables. For example, to display student names with their subject names using INNER JOIN, the query would be: SELECT Students.Name, Subjects.SubjectName FROM Students INNER JOIN Subjects ON Students.RollNo = Subjects.RollNo. This matches records where RollNo in both tables are the same.

You might also like