A science class records plant growth experiment data in a table called EXPERIMENT. ReadingID PlantID Condition Day Height LeafCount EX01 P1 Sunlight 1 5.0 4...

Assessment: Computer Science 0478 | Paper 2 Mock 01 | Algorithms, Programming and Logic Subject: Computer Science - 0478

Question 1 Report

A science class records plant growth experiment data in a table called EXPERIMENT.

ReadingIDPlantIDConditionDayHeightLeafCount
EX01P1Sunlight15.04
EX02P2Shade15.04
EX03P3Sunlight14.53
EX04P1Sunlight712.08
EX05P2Shade77.55
EX06P3Sunlight711.07
EX07P1Sunlight1418.012
EX08P2Shade149.06

(a) Write an SQL query to find the average Height for each Condition on Day 7. [3]

Answer Details

(a) Finding the average height by condition on day 7: [3]

SELECT Condition, AVG(Height)
FROM EXPERIMENT
WHERE Day = 7
GROUP BY Condition

[1] for AVG(Height), [1] for WHERE Day = 7, [1] for GROUP BY Condition.

The WHERE clause first filters to only Day 7 readings, then GROUP BY splits them by Condition:

  • Day 7 Sunlight readings: P1 (12.0) and P3 (11.0). Average = (12.0 + 11.0) / 2 = 11.5
  • Day 7 Shade readings: P2 (7.5). Average = 7.5 / 1 = 7.5

Expected output:

ConditionAVG(Height)
Sunlight11.5
Shade7.5

This result shows that plants grown in sunlight averaged 4.0 cm taller than the shade plant on day 7, which is a meaningful scientific observation. Note that the WHERE filtering happens before the GROUP BY aggregation.

Download The App On Google Playstore

Everything you need to excel in your exams

Green Bridge CBT Mobile App
Personalized AI Learning Chat Assistant
200,000+ Exam Questions Across IGCSE, JAMB, WAEC & NECO
Over 3,900 Lesson Notes
Offline Support - Learn Anytime, Anywhere
Green Bridge Timetable
Literature Summaries & Potential Questions
Track Your Performance & Progress
In-depth Explanations for Comprehensive Learning