← Years 7–8 Data & Information

Sorting and filtering a database table

Sort puts records in order by one field, either ascending (A to Z, small to big) or descending. Filter shows only the records that match a chosen value and hides the rest.

Understanding Sorting and filtering a database table in Years 7–8 Data & Information

What it does: Descending puts the biggest values first, so the highest score appears at the top. Filtering by selection on Class = 7B shows only matching records and hides the rest. Ascending text goes A to Z, so Adams comes before Zhang. Ascending numbers go from smallest to biggest. The second list is descending. Ascending means going up, so small numbers (or A to Z) come first. A sort in a table view works on one field, and descending is the option that gives Z to A order.

Common mistakes: The filter value is text, so it needs quotes. Without them the database looks for a field called Dog. It should be WHERE Type = 'Dog'. Sorting uses the words ORDER BY. The BY is missing. It should be ORDER BY Age ASC;.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 47–80) and word search (Modules 9–80).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
A database table has a Score field. You want the highest score at the top. Which sort do you use?
Descending (big to small)Ascending (small to big)
Matches
Sort Ascending on Surname and Age at the same time to put names in Z to A order
↓
Ascending sorts A to Z, not Z to A, and this sort should use one field only. Use Sort Descending on Surname to get Z to A.
Applying
Meanings
Term
sort and filter
Meaning
Sort puts records in order by one field, either ascending (A to Z, small to big) or descending. Filter shows only the records that match a chosen value and hides the rest.
Practice
Table: Pets
Testing
Gaps
by Name, Ascending
Check Answer
Spots
1SELECT * FROM Pets
2WHERE Type = Dog

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Jellyfish' badge — Flow Controller, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. A database table has a Score field. You want the highest score at the top. Which sort do you use?
A. Descending (big to small) ✓
B. Ascending (small to big)
Descending puts the biggest values first, so the highest score appears at the top.
2. You sort a Surname field in ascending order. Which surname comes first?
A. Adams ✓
B. Zhang
Ascending text goes A to Z, so Adams comes before Zhang.
3. You want to see only the records where Year Level is 8 and hide all the others. What do you use?
A. Sort
B. Filter ✓
Filter shows only the records that match a value. Sort only changes the order and keeps every record visible.
4. What happens to the records that do not match when you filter a table?
A. They are hidden from view ✓
B. They are deleted forever
Filtering only hides records. They are still in the table and come back when you clear the filter.
5. Which is true about sorting a table by one field?
A. Only the records that match are kept
B. Every record stays, but they are put in a new order ✓
Sorting rearranges the records by one field. Showing only matching records is what filtering does.

Match the Pairs

Sort Ascending on Age → Puts the records in order from the smallest age to the biggest age
Filter by Selection: Year = 8 → Shows only the records where the Year field is 8 and hides all the others
Sort the Players table so the highest score is at the top → Sort Descending on Score
Show only the students who are in class 7B → Filter by Selection: Class = 7B
Sort Ascending on Surname and Age at the same time to put names in Z to A order → Ascending sorts A to Z, not Z to A, and this sort should use one field only. Use Sort Descending on Surname to get Z to A.
Filter by Selection: Team = Red, then expect the Blue team records to still be shown → A filter hides every record that does not match. Blue team records are hidden when filtering on Red. Remove the filter to see all records again.

Key Term

sort and filter
Sort puts records in order by one field, either ascending (A to Z, small to big) or descending. Filter shows only the records that match a chosen value and hides the rest.

Fill in the Blanks

1. Sort by Name, Ascending
Hint: Type the action that puts records in order by one field.
2. Fields: Name, Score Sort by Score, Descending
Hint: Type the direction that puts the biggest scores at the top.
3. Pets table: Name, Age, Type Filter Type = "Cat"
Hint: Type the action that shows only matching records and hides the rest.
4. Pets table: Name, Age, Type Filter Type = "Dog"
Hint: Type the operator that checks a field matches a chosen value.
5. Goal: youngest pet first Sort by Age, Ascending
Hint: Type the field that stores how many years each pet has lived.

Spot the Error

Question 1
A SELECT * FROM Pets
B WHERE Type = Dog
C ORDER BY Age;
Line B — The filter value is text, so it needs quotes. Without them the database looks for a field called Dog. It should be WHERE Type = 'Dog'.
Question 2
A SELECT Name, Age FROM Pets
B WHERE Type = 'Cat'
C ORDER Age ASC;
Line C — Sorting uses the words ORDER BY. The BY is missing. It should be ORDER BY Age ASC;
Question 3
A SELECT * Games
B WHERE Year = 8
C ORDER BY Score DESC;
Line A — The table name must come after the word FROM. It should be SELECT * FROM Games.
Question 4
A -- Show oldest pets first
B SELECT * FROM Pets
C ORDER BY Age ASC;
Line C — ASC (ascending) puts the smallest ages first, so the youngest pets would appear first. To show the oldest first you need descending: ORDER BY Age DESC;
Question 5
A SELECT * FROM Books
B WHERE Genre = 'Sci-Fi
C ORDER BY Title ASC;
Line B — The text value is missing its closing quote. It should be WHERE Genre = 'Sci-Fi'

Student with a class code? Join your class →