Aan de slagGa gratis aan de slag

Applying various string functions on data

As you may have noticed, string functions are really useful for manipulating data. SQL Server offers a lot of built-in functions for string manipulation and some of them are quite fun to use. In this exercise, you are going to apply several string functions to the data from the voters table, to show it in a more presentable manner.

You will get the chance to use functions like: LEN(), UPPER(), PATINDEX(), CONCAT(), REPLACE() and SUBSTRING().

Remember: when searching for patterns within a string, these are the most helpful:

pattern match
% any string of zero or more characters
_ any single character
[] any single character within the range specified in brackets

Deze oefening maakt deel uit van de cursus

Functions for Manipulating Data in SQL Server

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

SELECT
	first_name,
    last_name,
	birthdate,
	email,
	country
FROM voters
   -- Select only voters with a first name less than 5 characters
WHERE ___(___) < 5
   -- Look for the desired pattern in the email address
	AND ___(___, ___) > 0;
Code bewerken en uitvoeren