Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases Reporting with SQL Working with Text Concatenating Text

im not sure what im doing wrong with my code, can someone please tell me what im doing wrong

In an ecommerce database there's a addresses table. There is an id, nickname, street, city, state, zip, country and user_id columns.

Concatenate the street, city, state, zip and country in the following format. street, city, state zip. country e.g. 34 NE 12 st, Portland, OR 97129. USA

Alias the concatenated string as address

We won't know unless you share your code.

Sorry about that, here is my code.

SELECT street || " " || city || " " || state || " " || zip || " " || country || " " || AS address FROM addresses

4 Answers

You are missing a few punctuations, and you have concatenated an extra unnecessary space at the end. Here's what the format should look like (with emphasis surrounded by asterisks): street*,* city*,* state zip*.* country

Your code

SELECT street || " " || city || " " || state || " " || zip || " " || country || " " || AS address FROM addresses

So the code should be: SELECT street, city, zip, country AS address FROM addresses;

You are missing ||s and quote marks. Also the punctuation after the zip should be a period not a comma. You are also missing the state.

SELECT street || ", " || city || ", " || state || " " || zip || ". " || country AS address FROM address;

i try and try and im stuck in the error.

my code is : SELECT street || ", " ||city|| ", " ||state|| " " ||zip|| '.' ||country as address from addresses;

and the message is this:Your query didn't retireve the addresses in the correct format. Expecting 2532 2nd ST, San Diego, California 90222. USA not 2532 2nd ST, San Diego, California 90222.USA.

I cant seem to get right how to separate 90222.USA to 90222. USA. Ive tried " " after and before ||country and nothing.

i figured it out