0% found this document useful (0 votes)
56 views4 pages

Class 12 IT MySQL Queries Detailed

The document contains a detailed practical file for Class 12 IT focusing on MySQL queries related to a 'student' table. It includes various SQL queries for retrieving and manipulating student data, such as displaying records, filtering by marks and gender, and performing aggregate functions. Each query is accompanied by an explanation of its purpose and functionality.

Uploaded by

pandeyvinu0507
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)
56 views4 pages

Class 12 IT MySQL Queries Detailed

The document contains a detailed practical file for Class 12 IT focusing on MySQL queries related to a 'student' table. It includes various SQL queries for retrieving and manipulating student data, such as displaying records, filtering by marks and gender, and performing aggregate functions. Each query is accompanied by an explanation of its purpose and functionality.

Uploaded by

pandeyvinu0507
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 IT Practical File - MySQL Queries (Detailed)

Table Used: student

| RollNo | Name | Class | Section | Gender | Marks |

|--------|--------|-------|---------|--------|-------|

|1 | Rahul | 12 |A | Male | 85 |

|2 | Priya | 12 |A | Female | 92 |

|3 | Ankit | 12 |B | Male | 76 |

|4 | Sneha | 12 |B | Female | 88 |

|5 | Aman | 12 |A | Male | 67 |

|6 | Simran | 12 |C | Female | 90 |

|7 | Rohan | 12 |C | Male | 73 |

|8 | Neha | 12 |B | Female | 81 |

1. Display all records from the student table

Query:

SELECT * FROM student;

Explanation:

This query retrieves all columns and records from the table.

2. Display name and marks of all students

Query:

SELECT Name, Marks FROM student;

Explanation:

This query fetches only the Name and Marks columns of all students.

3. List students who scored more than 80 marks

Query:

SELECT * FROM student WHERE Marks > 80;


Class 12 IT Practical File - MySQL Queries (Detailed)

Explanation:

Filters and displays students who have secured more than 80 marks.

4. Show details of students from section 'A'

Query:

SELECT * FROM student WHERE Section = 'A';

Explanation:

Displays all details of students who belong to section A.

5. Display names of female students

Query:

SELECT Name FROM student WHERE Gender = 'Female';

Explanation:

Fetches only the names of female students.

6. List students with marks between 70 and 90

Query:

SELECT * FROM student WHERE Marks BETWEEN 70 AND 90;

Explanation:

Shows students whose marks are between 70 and 90 inclusive.

7. Sort students by marks in descending order

Query:

SELECT * FROM student ORDER BY Marks DESC;

Explanation:
Class 12 IT Practical File - MySQL Queries (Detailed)

Displays all students sorted from highest to lowest marks.

8. Count the total number of students

Query:

SELECT COUNT(*) FROM student;

Explanation:

Returns the total number of student records in the table.

9. Find average marks of students

Query:

SELECT AVG(Marks) FROM student;

Explanation:

Calculates and displays the average marks of all students.

10. Find the highest marks

Query:

SELECT MAX(Marks) FROM student;

Explanation:

Shows the highest marks scored among all students.

11. Find the lowest marks

Query:

SELECT MIN(Marks) FROM student;

Explanation:

Shows the lowest marks scored among all students.


Class 12 IT Practical File - MySQL Queries (Detailed)

12. List distinct sections in the student table

Query:

SELECT DISTINCT Section FROM student;

Explanation:

Displays all unique sections without duplicates.

13. Show names of students whose names start with 'S'

Query:

SELECT * FROM student WHERE Name LIKE 'S%';

Explanation:

Displays students whose names begin with the letter 'S'.

14. List male students sorted by name

Query:

SELECT * FROM student WHERE Gender = 'Male' ORDER BY Name;

Explanation:

Lists male students in alphabetical order of their names.

15. Group students by gender and count them

Query:

SELECT Gender, COUNT(*) FROM student GROUP BY Gender;

Explanation:

Groups students by gender and counts how many in each group.

You might also like