Extracting a substring
In this exercise, you will extract parts of a string. You will work with data from the voters table.
There is a built-in function that can help you with this task. The parameters required by this function are:
- the expression from which the substring is extracted;
- the starting position of the substring
- and its length.
Keep in mind that the position of the first character in a string is 1, not 0. This will help you to correctly calculate the starting position of the substring.
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Functions for Manipulating Data in SQL Server
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
SELECT
email,
-- Extract 5 characters from email, starting at position 3
___ AS some_letters
FROM voters;