IniziaInizia gratis

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

Questo esercizio fa parte del corso

Functions for Manipulating Data in SQL Server

Visualizza il corso

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

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;
Modifica ed esegui il codice