Reputation: 3
Write a query to display “How many characters are there in each employee’s last name before the first 'e' or 'E' appears?”
Upvotes: 0
Views: 67
Reputation: 1270091
That is pretty much what the built in function INSTR()
does - well, technically, it finds the positions of the 'e'
so what you want is one less than that number.
To be safe, you can write this as:
select instr(lower(last_name) || 'e', 'e') - 1
This concatenates the 'e'
to the name to be sure it returns all characters when there is no 'e'
.
Upvotes: 2