-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path3374. First Letter Capitalization II.sql
More file actions
30 lines (25 loc) · 1.11 KB
/
3374. First Letter Capitalization II.sql
File metadata and controls
30 lines (25 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
Question 3374. First Letter Capitalization II
Link: https://leetcode.com/problems/first-letter-capitalization-ii/description/?envType=problem-list-v2&envId=database
Table: user_content
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| content_id | int |
| content_text| varchar |
+-------------+---------+
content_id is the unique key for this table.
Each row contains a unique ID and the corresponding text content.
Write a solution to transform the text in the content_text column by applying the following rules:
Convert the first letter of each word to uppercase and the remaining letters to lowercase
Special handling for words containing special characters:
For words connected with a hyphen -, both parts should be capitalized (e.g., top-rated → Top-Rated)
All other formatting and spacing should remain unchanged
Return the result table that includes both the original content_text and the modified text following the above rules.
*/
-- The easiest solution :)
SELECT
content_id,
content_text AS original_text,
INITCAP(content_text) AS converted_text
FROM user_content