SQL Revision for IEB Grade 12\\SQL
Revision for Grade 12 IEB – Complete
Study Guide 2026
The aggregate functions for biggest and smallest
MIN, MAX
The aggregate function for how many
COUNT
The aggregate function for adding up
SUM
The aggregate function for average
AVG
SELECT MIN(Temperature) AS LowestTemperature
FROM TblWeather
WHERE MONTH(Date) = 6
June's lowest temperature
SELECT ROUND(AVG(Mark))
FROM TblMarks
The average mark rounded off to no decimal places
SELECT ROUND(AVG(Age),2)
FROM TblStudents
Average age rounded to 2 decimal places
SELECT Grade, MAX(Mark)
FROM TblMarks
GROUP BY Grade;
The highest mark for each grade
SELECT MONTH(Date), MIN(Temperature)
FROM TblWeather
GROUP BY MONTH(Date)
The lowest temperature for each month
, Instead of a WHERE using the aggregate function with a GROUP BY use...
HAVING
SELECT genre, count(*)
FROM tblCD
GROUP BY genre
HAVING count(*) > 10
Shows number of CD's per genre with number greater than 10
SELECT CD_Name, Artist, ReplacementValue
FROM CD_table
WHERE ReplacementValue BETWEEN 90 AND 100
Shows CD's with cost from 90 to 100 (inclusive)
SELECT OwnerName
FROM Owner_Table
WHERE OwnerName BETWEEN 'M' AND 'S'
Shows names from M... to R... (does not show any S... names)
SELECT OwnerName,Grade
FROM Owner_Table
WHERE Grade IN (8,9,10)
Shows all owners in Grades 8, 9 and 10
SELECT Surname, Cell
FROM Learner
WHERE Cell LIKE '083*'
Shows all people with Cells starting with '083'
Keyword for finding data that looks like a certain pattern of data
LIKE
SELECT Province
FROM tblCountry
WHERE Province LIKE '??'
Shows all provinces which are 2 letters long
SELECT Name, DateOfBirth
FROM Owner_Table
WHERE DateOfBirth LIKE '/06/'
Shows all those with Month of Birth of 06
Revision for Grade 12 IEB – Complete
Study Guide 2026
The aggregate functions for biggest and smallest
MIN, MAX
The aggregate function for how many
COUNT
The aggregate function for adding up
SUM
The aggregate function for average
AVG
SELECT MIN(Temperature) AS LowestTemperature
FROM TblWeather
WHERE MONTH(Date) = 6
June's lowest temperature
SELECT ROUND(AVG(Mark))
FROM TblMarks
The average mark rounded off to no decimal places
SELECT ROUND(AVG(Age),2)
FROM TblStudents
Average age rounded to 2 decimal places
SELECT Grade, MAX(Mark)
FROM TblMarks
GROUP BY Grade;
The highest mark for each grade
SELECT MONTH(Date), MIN(Temperature)
FROM TblWeather
GROUP BY MONTH(Date)
The lowest temperature for each month
, Instead of a WHERE using the aggregate function with a GROUP BY use...
HAVING
SELECT genre, count(*)
FROM tblCD
GROUP BY genre
HAVING count(*) > 10
Shows number of CD's per genre with number greater than 10
SELECT CD_Name, Artist, ReplacementValue
FROM CD_table
WHERE ReplacementValue BETWEEN 90 AND 100
Shows CD's with cost from 90 to 100 (inclusive)
SELECT OwnerName
FROM Owner_Table
WHERE OwnerName BETWEEN 'M' AND 'S'
Shows names from M... to R... (does not show any S... names)
SELECT OwnerName,Grade
FROM Owner_Table
WHERE Grade IN (8,9,10)
Shows all owners in Grades 8, 9 and 10
SELECT Surname, Cell
FROM Learner
WHERE Cell LIKE '083*'
Shows all people with Cells starting with '083'
Keyword for finding data that looks like a certain pattern of data
LIKE
SELECT Province
FROM tblCountry
WHERE Province LIKE '??'
Shows all provinces which are 2 letters long
SELECT Name, DateOfBirth
FROM Owner_Table
WHERE DateOfBirth LIKE '/06/'
Shows all those with Month of Birth of 06