Databases Reporting with SQL Working with Text Concatenating Text

I 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
PRO
KRIS NIKOLAISEN
Pro Student 47,300 Points

The 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
PRO
KRIS NIKOLAISEN
Pro Student 47,300 Points

In aliasing you provide a name to the columns you have concatenated using the keyword AS:

SELECT column1 || ' ' || column2 AS to_field FROM table

What 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
Mike Jensen
11,718 Points

Your 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).