Thanks to visit codestin.com
Credit goes to www.scribd.com

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

SQL GroupBy Worksheet Class12

The document contains a table of students with their IDs, names, classes, and marks. It includes SQL queries to calculate average marks per class, count students in each class, identify classes with average marks above 75, find classes with total marks between 200 and 300, and count students whose names start with 'A' grouped by class. These queries provide insights into student performance and demographics within the classes.

Uploaded by

uma divan
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)
13 views1 page

SQL GroupBy Worksheet Class12

The document contains a table of students with their IDs, names, classes, and marks. It includes SQL queries to calculate average marks per class, count students in each class, identify classes with average marks above 75, find classes with total marks between 200 and 300, and count students whose names start with 'A' grouped by class. These queries provide insights into student performance and demographics within the classes.

Uploaded by

uma divan
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/ 1

Table 1: Students

Sample Data:
ID Name Class Marks
1 Anu XII-A 85
2 Binu XII-B 67
3 Ciya XII-A 90
4 Dev XII-B 78
5 Eva XII-A 72

Q1: Find average marks of each class.


SELECT Class, AVG(Marks) AS Avg_Marks FROM Students GROUP BY Class;

Q2: Count the number of students in each class.


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

Q3: Find classes with average marks greater than 75.


SELECT Class, AVG(Marks) AS Avg_Marks FROM Students GROUP BY Class HAVING AVG(Marks) >
75;

Q4: Find classes where total marks are between 200 and 300.
SELECT Class, SUM(Marks) FROM Students GROUP BY Class HAVING SUM(Marks) BETWEEN 200 AND
300;

Q5: Display count of students whose name starts with 'A' grouped by class.
SELECT Class, COUNT(*) FROM Students WHERE Name LIKE 'A%' GROUP BY Class;

You might also like