Free 1Z0-071 Restricting and Sorting Data Questions and Answers
How would you retrieve all rows from a table named employees where the salary is greater than 50000?
Correct!
Wrong!
The correct SQL query to retrieve rows where the salary is greater than 50000 is SELECT * FROM employees WHERE salary > 50000;
Which SQL clause is used to filter rows returned by a query based on a specified condition?
Correct!
Wrong!
The WHERE clause is used to filter rows in a SQL query based on specific conditions. It restricts the data that is retrieved from the database.
What does the ORDER BY clause do in a SQL query?
Correct!
Wrong!
The ORDER BY clause is used to sort the result set of a query based on one or more columns in ascending or descending order.
How can you retrieve only the top 5 highest-paid employees from the employees table?
Correct!
Wrong!
Which SQL statement will return all employees in the employees table sorted by their last_name in ascending order?
Correct!
Wrong!
The correct SQL query to sort employees by their last_name in ascending order is SELECT * FROM employees ORDER BY last_name ASC;. The ASC keyword specifies ascending order, which is also the default if not explicitly stated.