Very Easy
Show all students with long first names
Select all students in the students
table who have a first name with a length of exactly 7 characters. Sort the results by first name in ascending alphabetical order.
SCHEMA
students
+------------+------------+-----------+-----+------------+
| student_id | first_name | last_name | age | class_code |
+------------+------------+-----------+-----+------------+
| 1 | Mike | Chaplin | 12 | 7A |
| 2 | Emily | Jackson | 12 | 7A |
| 3 | Robert | Jackson | 12 | 7A |
| ... | ... | ... | ... | ... |
+------------+------------+-----------+-----+------------+
EXPECTED OUTPUT
+-------------+--------+
| first_name | length |
+-------------+--------+
| Beverly | 7 |
| D'Shawn | 7 |
| ... | ... |
+-------------+--------+
Use the keyword LENGTH() to get the length of an item.
SELECT
first_name,
LENGTH(first_name)
FROM students
WHERE LENGTH(first_name) = 7
ORDER BY first_name ASC