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 trialSam Beattie
2,413 PointsI don't know what I'm missing on this challenge in the Reporting with SQL track. I need to "Alias it to to_field."
I've done a number of combinations and haven't been able to find the correct format.
3 Answers
KRIS NIKOLAISEN
54,971 PointsThe alias 'to_field' applies to all three columns - first_name, last_name and email concatenated. Like this:
SELECT first_name || ' ' || last_name || ' <' || email || '>' AS to_field FROM patrons;
KRIS NIKOLAISEN
54,971 PointsIn aliasing you provide a name to the columns you have concatenated using the keyword AS:
SELECT column1 || ' ' || column2 AS to_field FROM table
Sam Beattie
2,413 PointsWhat I have tried: SELECT first_name || " " || last_name AS "Full Name", email AS "Email" FROM patrons; SELECT first_name || ' ' || last_name AS "Full Name", email AS "to_field" FROM patrons; SELECT first_name || ' ' || last_name AS "to_field", email AS "Email" FROM patrons;
What I get every time I check and recheck work: Bummer: Your query needs didn't retireve the emails in the correct format.
Please let me know if you can spot where I'm missing something or adding something that is not needed. Thank you!
Mike Jensen
11,718 PointsYour sample solutions have correct syntax, so you had no issues learning and applying the language concepts taught in this and previous videos.
Your problem was simply that you did not read the question correctly and follow the exact instructions. The question asked you to write a query which returns a single column titled "to_field". The column should be a concatenation of the first_name, last_name and email values, with some formatting, like this:
column 1 ("to_field"): FIRSTNAME LASTNAME <EMAIL>
You were close, but because you weren't following the instructions, you were retrieving the email as a second column, like this:
column 1 ("to_field"): FIRSTNAME LASTNAME
column 2 ("email"): EMAIL
This is wrong because it is not what was requested.
Kris Nikolaisen's solution is correct, but you should remember, reading comprehension is a fundamental skill to a successful career in programming (among others).