Before you start
You need Workbench and a running SQL engine. Every example includes its own input rows. No catalog, files, credentials, or external data is needed. These queries create no stored tables. Copy the SQL into Workbench and run the statements in order. Compare the result with the table below the query.WITH names input data for one statement only. Each example can run on its own.
1. Normalize case
Can names use the same case?
LOWER changes case and keeps spaces.
Change one thing: Use UPPER. Expect uppercase names with the same spaces.
2. Remove edge spaces
Can we remove surrounding spaces?
LTRIM and RTRIM remove spaces on the left and right.
Change one thing: Apply LOWER around the expression. Expect ada and ben.
3. Combine labels
Can we build a readable contact label?
CONCAT_WS joins values with a separator.
Change one thing: Change the separator to / . Expect UK-101/ Ada and US-202/ BEN.
4. Extract a prefix
What country prefix does each code contain?
SPLIT_PART selects a delimited field. Field positions start at one.
Change one thing: Use field position 2. Expect 101 and 202.
5. Replace text
Can codes use a slash separator?
REPLACE substitutes matching text.
Change one thing: Replace - with an empty string. Expect UK101 and US202.
6. Match a pattern
Which code starts with UK?
This regular expression checks the full code shape.
Change one thing: Replace UK with US. Only ID 2 appears.
7. Convert valid numbers
Can text become a number?
CAST converts a value when its text is valid for the target type.
Change one thing: Use DOUBLE as the target type. Numeric values stay 12 and 30.
8. Handle invalid numbers
Can invalid text become missing data?
TRY_CAST returns NULL for a failed supported conversion.
Change one thing: Use COALESCE(TRY_CAST(value AS INT), 0). ID 2 returns zero.