SQL/Dates & text 8 min
String functions
Concatenate, slice, clean and search text columns.
substrreplaceconcat
|| glues text together, and UPPER, LOWER and LENGTH do exactly what they say. These show up constantly when you build labels or keys.
sql · editable
loading editor…
SUBSTR cuts a slice out of a string and INSTR finds a character's position — combine them to split a full name into first and last.
sql · editable
loading editor…
Try it: Return just the first initial followed by a dot.
TRIM removes surrounding whitespace and REPLACE swaps substrings — the two workhorses of cleaning messy imports. LIKE and its wildcards handle pattern search.
sql · editable
loading editor…
Wrapping a column in a function stops an index on that column from being used. Filter on the raw column when you can, and store a cleaned copy when you cannot.
practice this