Consider the following table School-data:
Table : School-data
| Adm-no | Name | Grade | Club | Marks | Gender |
|---|---|---|---|---|---|
| 20150001 | Sargam Singh | 12 | STEM | 86 | Male |
| 20140212 | Alok Kumar | 10 | SPACE | 75 | Male |
| 20090234 | Mohit Gaur | 11 | SPACE | 84 | Male |
| 20130216 | Romil Malik | 10 | READER | 91 | Male |
| 20190227 | Tanvi Batra | 11 | STEM | 70 | Female |
| 20120200 | Nomita Ranjan | 12 | STEM | 64 | Female |
Write SQL queries for the following: (i) Display the average Marks secured by each Gender. (ii) Display the minimum Marks secured by the students of Grade 10. (iii) Display the total number of students in each Club where number of students are more than 1. OR (Option for Part (iii) only) (iii) Display the maximum and minimum marks secured by each gender.
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →Part (a): AVG(Marks) GROUP BY Gender; MIN(Marks) WHERE Grade=10 (=75); COUNT() GROUP BY Club HAVING COUNT()>1 (STEM 3, SPACE 2).
Part (b): MAX(Marks) and MIN(Marks) GROUP BY Gender — Male (91, 75), Female (70, 64).
The table School-data has a hyphen in its name, so it must be enclosed in backticks; otherwise SQL reads the hyphen as a minus operator. Parts (i) and (ii) are common to both options.
Part (a)
(i) Average marks by gender. GROUP BY Gender forms one bucket per gender and AVG(Marks) averages within each.
SELECT Gender, AVG(Marks) FROM `School-data` GROUP BY Gender;
Output:
Gender AVG(Marks)
Male 84.0
Female 67.0
(ii) Minimum marks in Grade 10. Filter to Grade 10 with WHERE, then take MIN. No grouping is needed for a single value.
SELECT MIN(Marks) FROM `School-data` WHERE Grade = 10;
Grade-10 students score 75 (Alok) and 91 (Romil):
MIN(Marks)
75
(iii) Clubs having more than one student. Count per club with GROUP BY Club, then keep groups whose count exceeds 1 using HAVING (a WHERE cannot filter on an aggregate).
SELECT Club, COUNT(*) FROM `School-data` GROUP BY Club HAVING COUNT(*) > 1;
STEM has 3 (Sargam, Tanvi, Nomita), SPACE has 2 (Alok, Mohit), READER has 1:
Club COUNT(*)
STEM 3
SPACE 2 …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.