SQLTeam.com | Weblogs | Forums

SQL query

You are working with a database table that contains customer data. The table includes columns about customer location such as city, state, and country . You want to retrieve the first 3 letters of each country name. You decide to use the SUBSTR function to retrieve the first 3 letters of each country name, and use the AS command to store the result in a new column called new_country .

You write the SQL query below. Add a statement to your SQL query that will retrieve the first 3 letters of each country name and store the result in a new column as new_country .

NOTE: The three dots (...) indicate where to add the statement.

I just don't seem to get after watching all the videos. Thank you. in advance for the help

Hi Webbyreach,

If you read the question it's pretty simple. First step is to know where the data is comming from.

SELECT country FROM the database table that contains customer data. Let's assume the table is dbo.customer then it will be

SELECT country
FROM dbo.customer;

If that is working you can use the SUBSTR function to select only the first 3 letters for the country and use AS new_country as a new column name.

SELECT SUBSTR(country) AS new_country
FROM dbo.customer;

This will give an error but you can use your favourite searchengine and search for SQL function SUBSTR to find the correct answer :wink:

2 Likes