Which of the following is the correct query to retrieve the last three characters from the 'City' column of the 'Customer' table?
A. SELECT LEFT(City, 3) FROM Customer;
B. SELECT RIGHT(City, 3) FROM Customer;
C. SELECT MID(City, 3) FROM Customer;
D. SELECT LENGTH(City, 3) FROM Customer;
Which of the following is the correct query to retrieve the last three characters from the 'City' column of the 'Customer' table?
A. SELECT LEFT(City, 3) FROM Customer;
B. SELECT RIGHT(City, 3) FROM Customer;
C. SELECT MID(City, 3) FROM Customer;
D. SELECT LENGTH(City, 3) FROM Customer;
Solution
RIGHT(string, n) returns the last characters of a string. So RIGHT(City, 3) gives the last three characters of every value in the 'City' column.
Option A (LEFT(City, 3)): returns the first three characters, not the last three.
Option C (MID(City, 3)): starts at position 3 and returns everything from there to the end of the string, so it is not fixed at three characters.
Option D (LENGTH(City, 3)): LENGTH() takes one argument and only returns the length of the string.
LEFT() and RIGHT() work as a pair, taking characters from the start and the end respectively.
Related questions:
2026: 23 May Shift 1
2026: 18 May Shift 2
2026: 13 May Shift 2
2025: 15 May Shift 2