0

What is the difference between for instance:

SELECT coalesce(a,b,c) AS d from table;

and

SELECT coalesce(a,b,c) d from table;

both returns the same result. Does it means that AS is optional?

4
  • 4
    If everything else fails, read the manual: postgresql.org/docs/current/static/… Commented Jan 28, 2015 at 13:07
  • @a_horse_with_no_name when you dont know what to look for, searching for the keyword AS in hundreds of pages of doc is helpless Commented Jan 28, 2015 at 13:12
  • When looking at a manual, you shouldn't be searching for keywords. The way I find things like that is to check the table of contents and then think which part might cover my question. As this is about a SELECT statement, Chapter 7 "Queries" looks like a good starting point. Then I open that, and I see a chapter "Select List Items" - and there you go. Reading a manual is not the same as using a search engine. Finding your way around manuals is just as important as learning the actual technology Commented Jan 28, 2015 at 13:17
  • yes you are right, I'll search deeper next time Commented Jan 28, 2015 at 13:19

1 Answer 1

3

Yes, it is optional. From the documentation: "The AS keyword is optional, but only if the new column name does not match any PostgreSQL keyword"

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you is this valid for any version?
@BelowtheRadar I would guess it is, although I haven't read the documentation for older versions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.