w3resource

SQL exercises on employee Database: List the names of those employees starting with 'A' and with six characters in length

SQL employee Database: Exercise-105 with Solution

[An editor is available at the bottom of the page to write and execute the scripts.]

105. Write a query in SQL to list the names of those employees starting with 'A' and with six characters in length.

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)

Practice Online


Sample Database: employee

employee database structure

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a query in SQL to list the no. of employees and average salary within each department for each job name.
Next: Write a query in SQL to list the employees whose name is six characters in length and third character must be 'R'.

What is the difficulty level of this exercise?



Inviting useful, relevant, well-written and unique guest posts