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.

Past paper questionOCR J277/02June 2025 Paper 27 marksSQL

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

  1. AND between the fields. Fields in a SELECT are separated by a comma: SELECT ActID, Stage.
  2. The wrong table. The question says the table is TblMusic. There is no TblActs.
  3. IF. SQL filters rows with WHERE.
  4. 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 the AND is 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.

It returns (1, Platinum) and (2, Hills), the two Saturday acts. Change Saturday to Sunday for acts 3 and 4.
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)
Put this demo on your own site

Paste it into a school website, Moodle, Google Sites or a blog. More options on the embed page.

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

Every OCR J277 question we have worked

Learn it step by step

  1. F7.3 SQL: SELECT Files and databases
  2. F7.2 Relational databases Files and databases
  3. F1.8 Data types and casting Programming basics
Open the lessons

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.