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 trial

Databases Reporting with SQL Working with Text Changing Cases of Strings

Maryam Naz
Maryam Naz
3,636 Points

how to combine "AS" statement so I wont have to re-type AS each time?

Hi all,

Solution 1 below does the job but isn't elegant. Anyway I can make Solution 2 work ( that is to only state "AS" once?

Solution 1: works, but I have to type "AS twice"

SELECT LOWER(title) AS lowercase_title, UPPER(author) AS uppercase_author FROM books;

Solution 2: how to combine all the "AS" together, to avoid retyping "AS", something example below?

SELECT LOWER(title) , UPPER(author) AS (lowercase_title, uppercase_author) FROM books;

1 Answer

Steven Parker
Steven Parker
231,275 Points

The first example is a correct solution. The second one is not proper SQL syntax, and aliases must be applied individually.

A common observation about SQL is that it tends to be a bit verbose and has very few "shortcut" variations in the syntax.

Maryam Naz
Maryam Naz
3,636 Points

Thanks Steven.

Steven Parker
Steven Parker
231,275 Points

Maryam Naz — Glad to help. You can mark a question solved by choosing a "best answer".
And happy coding!