Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Mask Sensitive Information | String Functions
Functions in SQL
Section 1. Chapter 5
single

single

bookChallenge: Mask Sensitive Information

Swipe to show menu

Task

Swipe to start coding

Write a SQL query that masks customer names, keeping only the first letter visible.

  • Select all columns from the customers table in the following order: id, name, masked_name, email, city
  • Add a computed column masked_name built as follows:
    • Extract the first character of the name using SUBSTRING(name, 1, 1)
    • Replace the remaining characters with asterisks using REPEAT('*', LENGTH(name) - 1)
    • Concatenate both parts using CONCAT()

Use the following functions: CONCAT(), SUBSTRING(), REPEAT(), LENGTH()

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 5
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

some-alt