Functions, Dates and Cleaning · Problem 24 of 118

Student Initials

EasyFunctions, Dates and CleaningSchool data

Return student_id and initials (the first letter of the first name followed by the first letter of the last name, in upper case) for students 1 to 10, sorted by student_id.

Hint 1

SUBSTR(text, 1, 1) is the first letter.

Reference solution

SELECT student_id,
       UPPER(SUBSTR(first_name, 1, 1) || SUBSTR(last_name, 1, 1)) AS initials
FROM students
WHERE student_id BETWEEN 1 AND 10
ORDER BY student_id;

Functions nest: the inner SUBSTR calls cut out one letter each, || joins them, and UPPER capitalises the result. Read nested calls from the inside out.