SQL Exercise: List the names of those employees starting with A
SQL employee Database: Exercise-105 with Solution
[An editor is available at the bottom of the page to write and execute the scripts.]
105. From the following table, write a SQL query to identify those employees whose names begin with 'A' and are six characters long. Return employee name.
Sample table: employees
Sample Solution:
SELECT emp_name
FROM employees
WHERE emp_name LIKE 'A%'
AND length(emp_name)=6;
Sample Output:
emp_name ---------- ADELYN ADNRES (2 rows)
Explanation:
The said query in SQL that selects the names of employees whose names start with 'A' and have a length of exactly 6 characters from the employees table.
The WHERE clause includes employees whose names starts with 'A' and the length() function to check if the length of the name is exactly 6 characters.
Practice Online
Sample Database: employee
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous SQL Exercise: List the number of employees and average salary.
Next SQL Exercise: Six-character employee names with R in 3rd position.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/sql-exercises/employee-database-exercise/sql-employee-database-exercise-105.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics