Skip to content
Advertisement

SQL Substring Case Condition

I’m trying to solve the following question on SQLPAD.

Write a query to return the number of actors whose first name starts with ‘A’, ‘B’, ‘C’, or others. The order of your results doesn’t matter. You need to return 2 columns: The first column is the group of actors based on the first letter of their first_name, use the following: ‘a_actors’, ‘b_actors’, ‘c_actors’, ‘other_actors’ to represent their groups. Second column is the number of actors whose first name matches the pattern.

Table: actor

Sample results

So far I’ve tried this:

Not sure how to check the others condition.

Advertisement

Answer

you need this. The question actually says specific for a,b,c and others. You are not doing specific for a.b.c

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement