Databases Reporting with SQL Working with Text Concatenating Text

Jordan young
Jordan young
Courses Plus Student 5,250 Points

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?


1 Answer

Megan Amendola
.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?

Jordan young
Jordan young
Courses Plus Student 5,250 Points

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?