OCR GCSE Computer Science June 2025 Paper 2, Question 6(b): four errors in an SQL statement
OCR J277/02 June 2025, Question 6(b): an SQL statement for the acts playing on Saturday has four errors: AND between fields, the wrong table, IF for WHERE, and no quotation marks. Each one corrected, plus records and data types, with the query to run.
Question 6(b) of the OCR GCSE Computer Science Paper 2 sat on 20 May 2025 (J277/02) shows an SQL statement that is wrong in four places, one for each mark. Two short parts follow, on records (1 mark) and data types (2 marks).
We do not copy the exam paper here. Open it beside this page: OCR June 2025 J277/02 question paper (PDF). When you have finished, check the mark scheme too.
The question in short
A database table called TblMusic stores the acts at a music festival. Its fields are ActID, Stage, Day and SetLength.
A statement should show ActID and Stage for all acts playing on Saturday. As written it says SELECT ActID AND Stage, then FROM TblActs, then IF Day = Saturday.
Part (i): find the four errors
ANDbetween the fields. Fields in aSELECTare separated by a comma:SELECT ActID, Stage.- The wrong table. The question says the table is
TblMusic. There is noTblActs. IF. SQL filters rows withWHERE.- No quotation marks. Saturday is text, so it must be
"Saturday". Without quotes, SQL looks for a field called Saturday.
SELECT ActID, Stage
FROM TblMusic
WHERE Day = "Saturday"
You can describe each change and still get the marks. Invalid SQL, the wrong order or extra code caps you at 3.
Part (ii): an example of a record
A record is one whole row: 1, Platinum, Saturday, 0.5. Any complete row from the table will do, or a sensible new one with all four items.
A definition ("a record is a row") is refused. The question asks for an example. One value, such as "Platinum", is a field's data and not a record.
Part (iii): the data types
Stage: string.SetLength: real (or float). Values such as 0.5 and 1.5 have a decimal part, so integer is wrong.
Where the marks are lost
- Spotting three errors and not the fourth. The wrong table name is the quiet one. Always check the table name against the sentence above the statement.
SELECT ActID Stage. Removing theANDis not enough. The comma is needed.SELECT *. The question asks for two fields.- Field names with spaces, such as
Act ID.
Run it
The corrected statement, run on the table from the paper. Put the paper's version into QUERY to see real SQL refuse it.
The program
from bugbot import *
import sqlite3
connect()
QUERY = 'SELECT ActID, Stage FROM TblMusic WHERE Day = "Saturday"'
db = sqlite3.connect(":memory:")
db.execute("CREATE TABLE TblMusic (ActID INTEGER, Stage TEXT, Day TEXT, SetLength REAL)")
rows = [(1, "Platinum", "Saturday", 0.5), (2, "Hills", "Saturday", 1.5),
(3, "Triangle", "Sunday", 1.0), (4, "Platinum", "Sunday", 0.5)]
db.executemany("INSERT INTO TblMusic VALUES (?, ?, ?, ?)", rows)
print(QUERY)
try:
for row in db.execute(QUERY).fetchall():
print(row)
except sqlite3.Error as problem:
led("red")
print("SQL error:", problem)
Questions
What is the answer to OCR J277 June 2025 Paper 2 Question 6(b)(i)?
SELECT ActID, Stage FROM TblMusic WHERE Day = "Saturday". The four corrections are the comma between the fields, the table name TblMusic, WHERE in place of IF, and quotation marks round Saturday.
What is the difference between a record and a field?
A record is one row of a table: all the data about one item. A field is one column: a single piece of data, such as Stage, that every record has.
How do you select more than one field in SQL?
List the field names after SELECT, separated by commas, such as SELECT ActID, Stage.
More from this paper
- Question 1: Normal, boundary and invalid test data, and a 1 to 100 range check 9 marks
- Question 2(a), (b): Count the passes of a flowchart loop, and describe the kinds of iteration 8 marks
- Question 3(a): Show the steps of a merge sort on eight numbers 4 marks
- Question 4: Complete an algorithm that reads numbers from a text file, and casting 6 marks
- Question 5(a), (b): A logic circuit from a description, and the truth table for A AND B 5 marks
Every OCR J277 question we have worked
Learn it step by step
- F7.3 SQL: SELECT Files and databases
- F7.2 Relational databases Files and databases
- F1.8 Data types and casting Programming basics
This is our own explanation of a published exam question. It is not written or endorsed by OCR, and the question paper and mark scheme remain OCR's copyright. Read them on OCR's site with the links on this page.