beginnercoding5 min
Basic SQL SELECT Statement
Write a SQL query to select the first name and last name of all employees from the 'employees' table where the department is 'Sales'.
Expected Answer
SELECT first_name, last_name FROM employees WHERE department = 'Sales';
Detailed Explanation
The SELECT statement is used to query data from a database. In this case, we are selecting two columns: 'first_name' and 'last_name' from the 'employees' table. The WHERE clause filters the results to include only those employees who belong to the 'Sales' department. This is a fundamental operation in SQL and is essential for retrieving specific data based on certain conditions.
Practice this concept in the browser.
SQL
Reset codeCopy codeFormat codeFull screen
Output
Practice mode output appears here.
Common Follow-up Questions
- What would you do if you wanted to sort the results by last name?
- How would you modify the query to count the number of employees in the Sales department?
- Can you explain the difference between SELECT * and SELECT specific columns?