aimnova.
DashboardMy LearningPaper MasteryStudy Plan

Aimnova site navigation

Stay in the loop

Get the latest study resources and updates

New features, study tips and exam insights — straight to your inbox.

IB Diploma

  • IB Past Papers
  • IB Study Notes
  • IB Question Bank
  • IB Mock Exams
  • IB Revision

IB Subjects

  • IB Math AA
  • IB Math AI
  • IB Economics
  • IB Business Management
  • IB Physics
  • IB Biology
  • View all IB subjects→

IB Past Papers

  • IB Math AA HL Past Papers
  • IB Math AA SL Past Papers
  • IB Math AI HL Past Papers
  • IB Math AI SL Past Papers
  • IB Economics HL Past Papers
  • IB Economics SL Past Papers
  • IB ESS Past Papers
  • View all past papers→

Study Resources

  • Study Notes
  • Question Bank
  • Mock Exams
  • Flashcards
  • Revision Guide
  • Exam Skills
  • Command Terms
  • Grade Calculator
  • Exam Timetable 2026

Aimnova

  • Features
  • Pricing
  • For Schools
  • For Parents
  • About Us
  • Blog
  • Contact
aimnova.

AI-powered study platform for smarter revision, past-paper analysis and examiner-style feedback.

TermsPrivacyCookies·© 2026 Aimnova. All rights reserved.8afc4e3

Aimnova is not affiliated with or endorsed by the International Baccalaureate Organization (IB).

NotesComputer Science HLTopic 3.3SQL aggregate functions
Back to Computer Science HL Topics
3.3.44 min read

SQL aggregate functions (Computer Science HL)

IB Computer Science • Unit 3

Your first topic is free to keep

Know exactly what to write for full marks

Practice with exam questions and get AI feedback that shows you the perfect answer — what examiners want to see.

Start Free

Contents

  • Many rows in, one number out
  • GROUP BY and HAVING
  • Nulls, and what aggregates ignore
  • Exam-style question
The big idea: An aggregate function collapses many rows into a single value.

COUNT how many · SUM the total · AVG the mean · MIN and MAX the extremes. Everything else in this topic is about controlling which rows they see.
COUNT(*) and COUNT(column) differ: COUNT(*) counts rows. COUNT(column) counts rows where that column is not null.

After a LEFT JOIN this is the difference between a customer with no orders scoring 1 and scoring 0 — and it is the single most examined detail here.

Free preview

This is the free notes preview

You're reading the free notes. Aimnova Pro unlocks the full study experience — and you can try it with your first topic free to keep:

  • FlashcardsLock in vocabulary and key terms with spaced repetition.
  • Practice questionsAnswer exam-style questions and get instant AI marking.
  • Mock exams & past-paper vaultSit full mocks and see exactly how examiners award marks.
  • Personalised study planA daily plan built around your exam date and weak areas.
Start Studying Free Full access to Aimnova Pro · cancel anytime
ClauseFiltersApplied
WHEREIndividual rowsBefore grouping
GROUP BY—Forms the groups
HAVINGWhole groupsAfter grouping
Why WHERE cannot test an aggregate: WHERE is evaluated row by row, before any group exists. At that moment there is no total to compare against — so WHERE SUM(total) > 50000 is not merely wrong, it is meaningless.

A condition on an aggregate needs HAVING, always.
Every non-aggregated column must be grouped: If a column appears in SELECT and is not inside an aggregate, it must appear in GROUP BY.

Otherwise the database is being asked which of several values to show for a group, and there is no answer.

Study smarter, not longer

Most students waste 40% of study time on topics they already know. Our AI tracks your progress and optimizes every minute.

Try Smart Study FreeYour first topic is free to keep • No credit card required

The behaviour to know

  • AVG, SUM, MIN, MAX ignore nulls — they are skipped, not treated as zero
  • So AVG over 10 rows with 3 nulls divides by 7, not 10
  • That is usually what you want — but only if you know it is happening
  • COUNT(*) is the exception: it counts every row regardless
  • A null is not zero and not an empty string — it is the absence of a value
State the divisor: If a question gives a column with missing values, say explicitly what AVG divides by. "The average is over the 7 rows that have a value, not all 10" is frequently the mark.

How this is tested — you must place a condition in WHERE or HAVING correctly and choose COUNT's argument deliberately. It comes up two ways:

Paper 1 Section A

  • Construct a query using an aggregate, 3-5 marks
  • State the difference between WHERE and HAVING
  • Give the result of an aggregate over given data

Paper 1 Section B — case study

  • Write a grouped query with a condition on the total
  • Explain why a query returns the wrong count
The classic trap: Putting a condition on a total into WHERE. WHERE runs before any group exists, so there is no total yet — it must be HAVING.
IB-style questionConstruct[5 marks]

Tables: Customer(customerID, name, city) and Order(orderID, customerID, total). Construct SQL listing each city with its number of customers and total revenue, including cities whose customers have never ordered, for cities with more than 10 customers.

Model answer plan

See the mark-by-mark plan — for / against / judgement, with marking guidance — in study mode.

Claim your free topic

IB Exam Questions on SQL aggregate functions

Practice with IB-style questions filtered to Topic 3.3.4. Get instant AI feedback on every answer.

Practice Topic 3.3.4 QuestionsBrowse All Computer Science HL Topics

How SQL aggregate functions Appears in IB Exams

Examiners use specific command terms when asking about this topic. Here's what to expect:

Define

Give the precise meaning of key terms related to SQL aggregate functions.

AO1
Describe

Give a detailed account of processes or features in SQL aggregate functions.

AO2
Explain

Give reasons WHY — cause and effect within SQL aggregate functions.

AO3
Evaluate

Weigh strengths AND limitations of approaches in SQL aggregate functions.

AO3
Discuss

Present arguments FOR and AGAINST with a balanced conclusion.

AO3

See the full IB Command Terms guide →

Related Computer Science HL Topics

Continue learning with these related topics from the same unit:

3.1.1Relational databases
3.2.1Database schemas
3.2.2ERDs
3.2.3Data types
View all Computer Science HL topics

Improve your exam technique

Command terms, paper structure, and mark-scheme tips for Computer Science HL

Previous
3.3.3Updating data with SQL
Next
Database views3.3.5

Make these notes count

Reading notes is just the start. Test yourself with IB-style questions and get feedback that shows you what examiners want.

Start FreeView All Computer Science HL Topics