Q14
1 markMCQSection A

What will be the output of the query ?

``sql

SELECT MACHINEID, MACHINENAME FROM INVENTORY

WHERE QUANTITY <= 100;

``

Structured Query Language (SQL)
SQL SELECT with WHERE Clause

Options

(A)All columns of INVENTORY table with quantity greater than 100
(B)ID and name of machines with quantity less than 100 from INVENTORY table
(C)All columns of INVENTORY table with quantity greater than or equal to 100
(D)ID and name of machines with quantity less than or equal to 100 from INVENTORY table.
Official Answer

Correct option: (D)


The query selects the MACHINEID and MACHINENAME columns only, for rows where QUANTITY is less than or equal to 100 — i.e., the ID and name of machines with quantity less than or equal to 100.

SELECT statementWHERE clausecomparison operatorless than equal toSQL query outputcolumn projection

Marking Scheme

  • 11 mark: correct option (D) selected.

Hint

Check exactly which columns follow SELECT and read <= as 'less than or equal to', not 'greater than'.

Quick Oral Answer

The query projects only MACHINE_ID and MACHINE_NAME for rows where QUANTITY is less than or equal to 100 — matching option (D).

Analysis & Explanation

This question checks understanding of the SELECT...WHERE clause with a comparison operator.


Why (D) is correct

  • Only MACHINEID and MACHINENAME are listed after SELECT, so only these two columns are displayed, not all columns.
  • The condition QUANTITY <= 100 means 'less than or equal to 100', which correctly matches option (D)'s wording.

Why the other options are wrong

  • (A) and (C) both wrongly claim 'all columns' are shown, but the SELECT list explicitly restricts output to two columns.
  • (A) also wrongly says 'greater than 100', which is the opposite of the actual condition.
  • (C) wrongly says 'greater than or equal to 100' and 'all columns', both incorrect.

Common Mistakes

  1. 1Misreading <= as 'greater than' instead of 'less than or equal to'.
  2. 2Assuming SELECT with specific column names still displays all columns of the table.

Interesting Facts

SQL comparison operators like <=, >=, <>, and BETWEEN are foundational to filtering data and are used in almost every real-world reporting query.

Choosing only specific columns in SELECT (called 'projection' in relational algebra) reduces the amount of data transferred, which is an important performance consideration in large databases.

Spotted a mistake or something unclear?

Tell us — we fix reported answers fast.

Frequently Asked Questions

What does the <= operator mean in SQL?

<= means 'less than or equal to'. In this query, QUANTITY <= 100 selects all rows where the quantity value is 100 or less, including exactly 100.

Why don't all columns of INVENTORY appear in the output?

Because the SELECT clause explicitly lists only MACHINE_ID and MACHINE_NAME. SQL displays only the columns named in SELECT; to display all columns, SELECT * would be required instead.