SQL Interview Questions – Fix Names in a Table

Spread the love

Problem Description –

Write an SQL query to fix the names so that only the first character is uppercase and the rest are lowercase.

Return the result table ordered by user_id.

The query result format is in the following example.

Problem Link – Fix Name

Difficulty Level – Easy

Solution –

SELECT
    user_id,
    CONCAT(UPPER(SUBSTR(name, 1, 1)), LOWER(SUBSTR(name, 2))) as name
FROM Users
ORDER BY 1

Rating: 1 out of 5.

Leave a Reply