SQL & Queries


Answer & solution
Official answer: A
Worked explanation
Evaluate the uncorrelated scalar subquery once. Filtering pno=P4 leaves prices 200 and 250, so its one group has average 225. Apply the outer strict comparison to every Catalogue row; prices 250,250,300,250 survive. The supplier primary key makes each surviving row join with exactly one supplier row, so the join neither loses nor multiplies them. Projection returns S2 once and S3 three times. SQL SELECT uses bag semantics unless DISTINCT is requested; it does not automatically collapse those repeated S3 names. The Parts table is not referenced by this query and cannot affect the count.
Derivation and answer
The P4 rows have costs 200 and 250, so the subquery returns 225. Catalogue costs greater than 225 occur at(S2, P5),(S3, P1),(S3, P5),(S3, P4): four rows. The supplier join preserves all four and SELECT has no DISTINCT, so repeated S3 output rows remain. Answer 4, A.