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 trialJorge Berbena
10,016 PointsWhatΒ΄s wrong whit this code?
I wrote this and I could not complete the challenge,
SELECT street|| ","|| " " || city || "," || " " || state || " , " || " " || zip || "."|| " " || country ||"." AS "address" FROM addresses;
1 Answer
jcorum
71,830 PointsJorge, you didn't give a link to the challenge, or the challenge requirements, I can't guarantee that this will pass the test, but it looks like you need something more like this:
SELECT street || ", " || city || ", " || state || " " || zip || ", " || country AS "address" FROM addresses;
Note that you can do this ", " (with the comma and the space in the same string, instead of in two concatenated strings ","|| " ". It is also "best practice" to leave spaces between operands and operators.
My code should return an address like this:
7 Pleasant St, Groton, MA 05405, USA (with no comma after the state and a comma after the zip code). You had a period after the zip code which I've also left out.
with a column heading of address -- the alias.
If the challenge wanted something different then you will have to make some adjustments.
Jorge Berbena
10,016 PointsJorge Berbena
10,016 PointsThanks, for your help. I left the space in the same string and issue was solved.