Multiple choice technology databases

Which SELECT statement should you use if you want to display unique combinations of the POSITION and MANAGER values from the EMPLOYEE table?

  1. SELECT DISTINCT position, manager FROM employee;

  2. SELECT position, manager DISTINCT FROM employee;

  3. SELECT position, manager FROM employee;

  4. SELECT position, DISTINCT manager FROM employee;

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

To solve this question, the user needs to know the syntax of the SELECT statement and the purpose of the DISTINCT keyword. The user must retrieve unique combinations of the POSITION and MANAGER values from the EMPLOYEE table.

Option A is the correct answer:

A. SELECT DISTINCT position, manager FROM employee;

This option retrieves unique combinations of the POSITION and MANAGER values from the EMPLOYEE table. The DISTINCT keyword ensures that each combination is unique and not repeated in the result set.

Option B is incorrect:

B. SELECT position, manager DISTINCT FROM employee;

This option is not valid because the keyword DISTINCT is in the wrong position. The correct syntax is SELECT DISTINCT, not SELECT column1, column2 DISTINCT.

Option C is incorrect:

C. SELECT position, manager FROM employee;

This option retrieves all combinations of the POSITION and MANAGER values from the EMPLOYEE table, including duplicates.

Option D is incorrect:

D. SELECT position, DISTINCT manager FROM employee;

This option is not valid because the keyword DISTINCT is in the wrong position. The correct syntax is SELECT DISTINCT, not SELECT column1, DISTINCT column2.

The Answer is: A

AI explanation

To retrieve only unique combinations of two or more columns, the DISTINCT keyword must immediately follow SELECT and applies to the entire row of listed columns together, not to a single column. 'SELECT DISTINCT position, manager FROM employee;' correctly returns each unique (position, manager) pair once. Placing DISTINCT after the column list ('position, manager DISTINCT') or before only one column ('position, DISTINCT manager') is invalid SQL syntax — DISTINCT isn't a per-column modifier. Omitting DISTINCT entirely ('SELECT position, manager FROM employee;') returns all rows including duplicates, not unique combinations.