Easy SQL Challenge: Using LIKE and Wild Card Search Operator (%)

365 Days of Daily Coding: Day 31

I had a good start of the day. I woke up early but ended up not using it productively. That is something I would like to change. I have read a lot of articles publicising about having a proper morning routine. It’s not really easy especially when its become a habit and you have been living the way for so long.

One of the habit that I am trying to work on is to wake up early and take a cold shower. I normally wake up and just lie in my bed playing my phone for like 1 hour which I find is really wasting my precious time. But geez, it’t not easy to break that cycle of habit that I have.

Anyway, for today’s challenge, I got a easy one. Given a table, I had to find out the last names that ended with “EN” or “RY”.

Table: actor

col_namecol_type
actor_idinteger
first_nametext
last_nametext
“actor” Table

Expected Solution:

last_namecount
Allen3
Berry2
Expected Solution
SELECT last_name, COUNT(*) 
FROM actor
WHERE UPPER(last_name) LIKE ('%EN') OR last_name LIKE ('%RY')
GROUP BY last_name;

Leave a comment