Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Databases Reporting with SQL Working with Text Concatenating Text

pinky
pinky
2,248 Points

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.

pinky
pinky
2,248 Points

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
pinky
pinky
2,248 Points

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;
Indhira Acevedo
Indhira Acevedo
1,894 Points

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.