Which query would efficiently retrieve the first name and last name of all employees in the 'Staff' table whose last name begins with the letter 'S' and are sorted in ascending order by their first name?
SELECT FirstName, Surname FROM Staff WHERE Surname LIKE 'S%';
SELECT * FROM Staff WHERE LastName = 'S*';
SELECT FirstName, LastName FROM Staff WHERE LastName LIKE 'S%' ORDER BY FirstName ASC;
SELECT FirstName, LastName FROM Staff WHERE LastName LIKE 'S%' ORDER BY FirstName DESC;
The correct answer is 'SELECT FirstName, LastName FROM Staff WHERE LastName LIKE 'S%' ORDER BY FirstName ASC;' because it includes all the necessary clauses for the specified conditions. It selects only the columns needed ('FirstName', 'LastName'), uses a WHERE clause with the LIKE operator to filter last names starting with 'S' (indicated by 'S%'), and sorts the results by 'FirstName' in ascending order. The other options are incorrect either due to missing the sorting condition ('ORDER BY'), incorrect sorting order, assuming a column that doesn't exist, or using incorrect wildcard character for selection.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does the 'LIKE' operator do in SQL?
Open an interactive chat with Bash
What is the significance of 'ORDER BY' in an SQL query?
Open an interactive chat with Bash
What is the purpose of using '%' in the query example?