Unable to filter multiple condition question

The codes I used is returning an error
Screen Link: Learn data science with Python and R projects
My Code:

SELECT *
 FROM employee
WHERE (SUBSTRING(hire_date, 1, 4) = '2017'
       AND (LENGTH(first_name) = 5 OR (first_name)= 6)
      );

I expected it to filter the hire_date based on 2017, but it keeps filtering 1985. Kindly help please!

Hey! Try changing the order of your query. In the exercise, you need to first find the length of first_name, which is either 5 or 6. And only after that, the hire_date should be in the year 2017.

Here is the query with correct order:
SELECT *
FROM employee
WHERE (LENGTH(first_name) = 5
OR LENGTH(first_name) = 6)
AND SUBSTRING(hire_date, 1, 4) = ‘2017’;

2 Likes