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. /An airline desk weighs hand luggage and stores the masses in a table Bags, in kilograms…
MediumComputer ScienceHigh School (9–10)Computer Science › Databases and SQLNumericalIGCSE

An airline desk weighs hand luggage and stores the masses in a table Bags, in kilograms…

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.

An airline desk weighs hand luggage and stores the masses in a table Bags, in kilograms.

table
BagID  Kg
B1     7
B2     3
B3     5
B4     2
B5     9
B6     6

Compare these two scripts.

sql
SELECT BagID FROM Bags WHERE Kg < 5;
SELECT BagID FROM Bags WHERE Kg <= 5;

How many records does each script output? Explain the difference.

Check your answer

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

Need a reminder? The key ideaShowHide

WHERE keeps only the records for which the condition is true. The operators are =, <>, >, <, >= and <=. Text goes in quotes, numbers do not, and a Boolean field is compared with TRUE or FALSE. The field in the condition need not be selected.

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 masses. 777, 333, 555, 222, 999 and 666 kilograms.

Step 2. Kg < 5. Only 3 kg3\ \text{kg}3 kg and 2 kg2\ \text{kg}2 kg are less than 5 kg5\ \text{kg}5 kg: B2 and B4. That is 222 records.

Step 3. Kg <= 5. B3 is exactly 5 kg5\ \text{kg}5 kg, so it passes too: B2, B3 and B4. That is 333 records.

Watch out. The two operators differ only for a value equal to the number in the condition.

Answer: 222 records and 333 records. B3, at exactly 5 kg5\ \text{kg}5 kg, passes <= but not <.

Log in to save this for later
← All Problems
← A city farm keeps a table of its animals, Animals…A school books rooms from this table. Write a script that outputs the room number of every room… →
More onComputer Science › Databases and SQL

Discussion (0)

Log in to join the discussion.

Loading…

Learn it in

  1. WHERE: choosing the recordsSQL Queries: SELECT, WHERE and ORDER BY

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 →