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

Sara Scott
Sara Scott
3,968 Points

REPORTING W/SQL Challenge Task 2 of 2

Help! Can't seem to figure this one out.

Sara Scott
Sara Scott
3,968 Points

My code:

 SELECT street AS "Street" || "," || " " || city AS "City" || "," || " " || state AS "State" || "," || " " || zip as "Zip" || "." " " || country as "Country" AS address FROM addresses; 

Supposed to show street, city, state, zip, country as Street, City, State, Zip. Country The example shows it like this...

3425 Winchester St, Portland, OR. USA

3 Answers

Sara Scott
Sara Scott
3,968 Points

Thanks guys!! I figured it out just after I posted. I should have saved the code and posted here for the next person who gets stuck. I just remember that it was picky, picky, picky about where the spaces, commas, and || were placed. Good practice though and good to discover that there IS an answer; the question is not flawed.

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

You're almost there, seems like a problem somewhere in your string concatenation.

The example is there as a guide for you.

Try this

 SELECT street AS "Street" || " " || city AS "City" || "," || " " || state AS "State" || "," || " " || zip as "Zip" || "." " " || country as "Country" AS address FROM addresses; 

miss out the first comma in your string concatenation and try that :-)

From what I can tell, you're miss a || toward the end, between zip as "Zip" and country as "Country"

SELECT street AS "Street" || "," || " " || city AS "City" || "," || " " || state AS "State" || "," || " " || zip as "Zip" || "." [RIGHT HERE] " " || country as "Country" AS address FROM addresses;

Hope this helps.

Also, you can put the comma/period and space parts together:

 SELECT street AS "Street" || " " || city AS "City" || ", " || state AS "State" || ", " || zip as "Zip" || ". " || country as "Country" AS address FROM addresses; 

Just another thought.