First Letter Capitalization - Problem

You have a user_content table containing text content that needs to be formatted with proper capitalization.

Table Structure:

  • content_id: Unique identifier for each content entry
  • content_text: The text content to be transformed

Task: Transform the text by capitalizing the first letter of each word while converting all other letters to lowercase. Preserve all existing spaces between words.

Return: A result table with both the original text and the converted text where each word starts with a capital letter.

Table Schema

user_content
Column Name Type Description
content_id PK int Unique identifier for content
content_text varchar Text content to be transformed
Primary Key: content_id
Note: Each row contains unique content that needs title case formatting

Input & Output

Example 1 — Basic Text Transformation
Input Table:
content_id content_text
1 hello world of SQL
2 the QUICK brown fox
3 data science AND machine learning
Output:
content_id original_text converted_text
1 hello world of SQL Hello World Of Sql
2 the QUICK brown fox The Quick Brown Fox
3 data science AND machine learning Data Science And Machine Learning
💡 Note:

Each word's first letter is capitalized while all other letters become lowercase. The function handles mixed case input like 'QUICK' and 'AND' by converting them to proper title case.

Example 2 — All Caps and Mixed Content
Input Table:
content_id content_text
4 TOP rated programming BOOKS
5 advanced sql QUERIES and optimization
Output:
content_id original_text converted_text
4 TOP rated programming BOOKS Top Rated Programming Books
5 advanced sql QUERIES and optimization Advanced Sql Queries And Optimization
💡 Note:

Words in all caps like 'TOP' and 'BOOKS' are converted to title case. The INITCAP function preserves spacing and handles any combination of uppercase and lowercase letters.

Constraints

  • content_id is unique for each row
  • content_text contains only letters and spaces
  • No special characters or punctuation in the text
  • 1 ≤ content_id ≤ 1000

Visualization

Tap to expand
First Letter Capitalization ProblemInput Tablecontent_idcontent_text1hello world2QUICK brown3TOP ratedINITCAPFunctionOutput Tablecontent_idoriginal_textconverted_text1hello worldHello World2QUICK brownQuick Brown3TOP ratedTop Rated
Understanding the Visualization
1
Input
Mixed case text content
2
Transform
Apply INITCAP function
3
Output
Title case formatted text
Key Takeaway
🎯 Key Insight: Use INITCAP when you need to standardize text formatting to proper title case
Asked in
Amazon 23 Microsoft 18 Google 15
23.4K Views
Medium Frequency
~8 min Avg. Time
892 Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen