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

Alias in Concatenation Reporting

Hi, in the second question of this challenge I don't quite understand the Aliasing that is happening here.

My code reads as follows:

SELECT Street || ", " || City || ", " || State || " " || Zip || ". " || Country AS "address" FROM addresses;

This is correct, but in the data fields in the table all lead with lower case (street, city, country, etc), and the format asks to concatenate the address as Street, City, Country.

Wouldn't we have to do alias every single of the cells in the dataset for our SQL query?

Like street AS "Street" etc?

Thanks!

1 Answer

Megan Amendola
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Megan Amendola
Treehouse Teacher

The challenge isn't asking you to change the column names to titlecase (street to Street). It is just saying to output the info in the typical address format which is Street, City, State Zip because you capitalize the street names, city names, and states names when you write an address out. It was just using that as an example of the column order. Do you think it would be less confusing if the column names were lowercase instead?

Thanks for your speedy reply Megan, as someone pretty new to SQL and the Pythonesque side of things, I think it would be less confusing given that the other code challenge elements (i.e. || " , " ||) are so particular on syntax/spacing/single vs. double quotes which generate the "Bummer" error. I'm trying to grasp all of the nuance of the code, and this really threw me off.

Maybe i'm in the minority though?

To be clear, NO aliasing does happen here without the AS keyword, right?