Databases Reporting with SQL Working with Text Creating Excerpts

Complex question please help

In an ecommerce database there's a customers table with id, username, first_name, last_name, password, email and phone columns. Create a report from the customers table that shows their first initial of their first name and alias it as initial. Select their last name too.

My answer: SELECT SUBSTR(<first_name>, <1>, <length>) AS "initial" AND SELECT SUBSTR (<last_name>, <1>, <length>);

This formula does not look right to me, I'm not quite sure what the question is asking of me to do and I don't know how to work out the length hence i left that blank could someone explain to me please

1 Answer

Steven Parker
Steven Parker
150,112 Points

It looks like you may have taken some documentation too literally. Documentation often surrounds terms in angle brackets to identify parameters that will be substituted by actual values. The angle brackets themselves are not part of the syntax, so "<first_name>" should just be "first_name". And "<length>" should be replaced by an actual number that represents the length.

And when the instructions say "Select their last name too" they mean the entire last name, you won't need to get a SUBSTR on that one.

Items in a select list should be separated by commas instead of the word "AND".

Finally, don't forget the "FROM" clause that names the table that the data will be coming from.