HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Problems
  2. /A school kitchen records each lunch order in a table Lunches…
MediumComputer ScienceHigh School (9–10)Computer Science › Databases and SQLNumericalConceptualIGCSE

A school kitchen records each lunch order in a table Lunches…

StemPy LabContributed by StemPy Lab

Try it on paper first. A hint, the key idea and the worked solution are here when you need them.

A school kitchen records each lunch order in a table Lunches. Hot says whether the meal is served hot.

table
LunchID  Meal   Hot    Portions
L1       Pasta  TRUE   3
L2       Salad  FALSE  2
L3       Curry  TRUE   4
L4       Wrap   FALSE  1
L5       Stew   TRUE   2

The cook asks two questions: "How many orders were for hot meals?" and "How many portions of hot food must I make?" Write a script for each and give its output.

Check your answer

Work it out on paper, then type your number. The answer itself stays hidden.

Need a reminder? The key ideaShowHide

COUNT(*) counts the records that pass the WHERE condition. SUM(Field) adds up a numeric field of the records that pass. Each gives one value. "How many orders?" is a count; "how many cups?" is a sum of the Cups field.

The worked solution

Have you tried it?

Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.

Step 1. The hot orders. L1, L3 and L5.

Step 2. The number of orders.

sql
SELECT COUNT(*)
FROM Lunches
WHERE Hot = TRUE;

The output:

table
COUNT(*)
3

Step 3. The number of portions.

sql
SELECT SUM(Portions)
FROM Lunches
WHERE Hot = TRUE;

The output:

table
SUM(Portions)
9

Check. 3+4+2=93 + 4 + 2 = 93+4+2=9 portions.

Answer: 333 hot orders and 999 portions.

Log in to save this for later
← All Problems
← A café keeps its orders in a table Orders. Cost is in dollars. Give the output of each script.A bus company stores each trip of one morning in a table Fares… →
More onComputer Science › Databases and SQL

Discussion (0)

Log in to join the discussion.

Loading…

Learn it in

  1. Counting and adding with COUNT and SUMSQL: SUM, COUNT, AND, OR and Reading Query Output

More on this topic

  1. A restaurant stores its staff in a table Staff…Hard
  2. A town library stores its readers in a table Readers…Medium
  3. A gym stores its members in a table Gym…Easy
  4. A school garden club records each plot in a table Plots: the water it needs each day in litres, its…
Hard
  • A school weather station stores one record a day in a table Weather: the rainfall in millimetres…Medium
  • All problems on this topic →