Get startedGet started for free

Using the beginning or end of a string

Sometimes you may need to take only certain parts of a string. If you know that those parts can be found at the beginning or the end of the string, remember that there are built-in functions that can help you with this task.

You will use these functions in this exercise. The purpose is to create an alias for each voter from the voters table, as a combination of the first 3 letters from the first name, the last 3 letters from the last name, and the last 2 digits from the birthday.

This exercise is part of the course

Functions for Manipulating Data in SQL Server

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

SELECT 
	first_name,
	last_name,
	country,
    -- Select only the first 3 characters from the first name
	___ AS part1
FROM voters;
Edit and Run Code