Standard difficulty · 20 questions · 40 marks · Time: 45 minutes
Show your working for Sections B and C. Answers are on the last page — try every question first!
SQL: Functions, GROUP BY and Joins · AW-12CS-SQG-2026-V1 · For parents — fold back or tear off before handing the sheet to your child.
| Q | Answer | Working |
|---|---|---|
| 1 | (d) LENGTH() | — |
| 2 | (d) 50000 | MIN(Salary) over rows where Dept = 'IT' |
| 3 | (a) 146.8750 | 1175 ÷ 8; AVG skips NULL |
| 4 | (d) 7 | COUNT(*) counts rows |
| 5 | (d) 3 | one row for each Category: Desk, Paper, Writing |
| 6 | (c) 1 | groups: HR 40000.0000; IT 33000.0000; Sales 49250.0000; HAVING keeps 1 |
| 7 | (b) 4 | only pairs with equal DeptID (and the extra condition) are kept |
| 8 | (a) 6 | NATURAL JOIN shows the common column DeptID once |
| 9 | COUNT(), SUM(), AVG(), MIN() and MAX(). | — |
| 10 | 12500 | SUM(Bonus) over rows where Dept = 'HR'; NULL is skipped |
| 11 | Sec | MAX(Marks) A | 97 B | 86 C | 93 | one row per Sec |
| 12 | Category | SUM(Price) Writing | 670 | groups before HAVING: Desk 170; Paper 170; Writing 670 |
| 13 | Name | City Priya | Shimla Rahul | Shimla Rohan | Pune Zoya | Indore | pair each EMP row with the DEPT row of the same DeptID |
| 14 | (a) 7; (b) 5 | 2 Bonus values are NULL, and COUNT(column) skips NULL |
| 15 | Dev, Rohan | NULL is tested with IS NULL, never with = NULL; 2 such rows |
| 16 | (a) 18; (b) 7 | 6 × 3 rows; 4 + 3 columns |
| 17 | COUNT(*) gives the number of items; SUM(Qty) the total quantity; AVG(Price) the mean price; MIN(Price) the cheapest price; MAX(Price) the dearest. Each returns one value for the rows selected, ignoring NULL. | — |
| 18 | (a) Category | COUNT(*) Desk | 4 Paper | 3 (b) 2 | WHERE filters rows before grouping; HAVING filters groups after |
| 19 | (a) Name | City Ananya | Indore Arjun | Jaipur Dev | Jaipur Meera | Indore (b) 4 rows, 6 columns; (c) an equi-join keeps both copies of the common column; a natural join shows it once. | join on equal DeptID |
| 20 | (a) SELECT Dept, COUNT(*) FROM EMPLOYEE GROUP BY Dept; (b) SELECT MAX(Salary), MIN(Salary) FROM EMPLOYEE WHERE Dept = 'HR'; (c) SELECT Dept FROM EMPLOYEE GROUP BY Dept HAVING SUM(Salary) > 100000; (d) SELECT Name FROM EMPLOYEE WHERE Bonus IS NULL; | GROUP BY with an aggregate; HAVING for a condition on groups; IS NULL |