TGViewer
SQL Programming Resources SQL Programming Resources @sqlanalyst · 76.7K subscribers
Post #2748 1.1K
You might get separate groups for Premium, premium, PREMIUM.

Instead:

SELECT UPPER(TRIM(customer_type)) AS customer_type, COUNT(*) AS customer_count 
FROM customers
GROUP BY UPPER(TRIM(customer_type));


Now logically equivalent values can be grouped together.

🧹 20. Cleaning Product Names

Suppose product names contain unnecessary spaces and inconsistent capitalization.

SELECT UPPER(TRIM(product_name)) AS cleaned_product_name FROM products;


You can also remove unwanted characters:

SELECT REPLACE(TRIM(product_name), '-', ' ') AS cleaned_product_name FROM products;


Example: ' wireless-earbuds ' can become wireless earbuds.

💼 21. Real-World Business Example

Suppose an e-commerce company stores customer names inconsistently.

You have ' alice ', 'ALICE', 'Alice', ' alice'

You can create a normalized version:

SELECT UPPER(TRIM(customer_name)) AS normalized_name FROM customers;


This produces ALICE, ALICE, ALICE, ALICE.

The cleaned value can be used for analysis or as part of a data-matching strategy.

String normalization alone does not guarantee that two records represent the same person.

🧩 22. Combining Multiple String Functions

SQL becomes particularly powerful when functions are combined.

SELECT UPPER(TRIM(customer_name)) AS cleaned_name FROM customers;
SELECT LOWER(TRIM(email)) AS cleaned_email FROM customers;
More from @sqlanalyst
  1. Oct 7, 2026🚀𝗣𝗮𝘆 𝗔𝗳𝘁𝗲𝗿 𝗣𝗹𝗮𝗰𝗲𝗺𝗲𝗻𝘁 𝗧𝗿𝗮𝗶𝗻𝗶𝗻𝗴 | 𝗕𝗲𝗰𝗼𝗺𝗲 𝗮 𝗙𝘂𝗹𝗹𝘀𝘁𝗮𝗰…
  2. Oct 7, 2026SQL Interview Series — Part 4 📌 Question 4: Find the Highest Salary in Each Department Su…
  3. Oct 7, 2026𝗠𝗮𝘀𝘁𝗲𝗿 𝗣𝗼𝘄𝗲𝗿 𝗕𝗜 𝗳𝗼𝗿 𝗙𝗥𝗘𝗘! 🔥 Learn Power BI through these FREE learnin…
  4. Sep 29, 2026SQL Interview Series — Part 2 📌 Question 2: Find Duplicate Records Suppose you have an Em…
  5. Sep 29, 2026𝗙𝗥𝗘𝗘 𝗥𝗲𝘀𝗼𝘂𝗿𝗰𝗲𝘀 𝗧𝗼 𝗟𝗲𝗮𝗿𝗻 𝗔𝗜 𝗶𝗻 𝟮𝟬𝟮𝟲🚀 ​ Explore 6 free resource…
  6. Sep 29, 2026SQL Interview Series — Part 1 Hi guys, let's start a SQL interview series covering frequen…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →