Databases Reporting with SQL Working with Text Concatenating Text

Michael Martin
Michael Martin
5,739 Points

This statement works in SQL Playground, aliasing three values as to_field, what am I doing wrong with this question?

select first_name || " " || last_name || " " || "<" || email || ">" as "to_field" from patrons where first_name = "Andrew"

What is wrong with this query? if I change the variables around, it works just fine in the playground, am I misunderstanding what to alias it to/as?

Michael Martin
Michael Martin
5,739 Points

I got this to work, didn't understand question.......................

1 Answer

Charlie Harcourt
Charlie Harcourt
8,029 Points

You've got a "" in between the last_name and the '<' where there shouldn't be one. In the playground it wont matter as it will just bring back the results. However, in the task it is asking for specific results so it will see that extra space and automatically think it's wrong.

try and compare your task to this. I have tested the code below and know this works.

SELECT first_name || " " || last_name || ' <' || email || '>' AS to_field FROM patrons;

:)

Michael Martin
Michael Martin
5,739 Points

I figured it out, I was looking at the question wrong, but I really appreciate your response