Management & CommerceModerateBusiness analyst · SQL test

Order 1 contains SKUs x and y; order 3 contains SKUs x, y and z. Query P combines the SKU lists of the two orders with UNION; query Q uses UNION ALL. How many rows does each return?

  1. A. P = 5, Q = 3
  2. B. P = 5, Q = 5
  3. C. P = 3, Q = 5
  4. D. P = 2, Q = 5

Correct answer: C. P = 3, Q = 5

UNION removes duplicate rows, leaving x, y, z (3 rows). UNION ALL keeps every row from both inputs: 2 + 3 = 5.

More Operations, Supply Chain & Business Analytics questions

Exams that ask this topic