E
E
Eugene Wolf2016-11-22 23:11:50
PostgreSQL
Eugene Wolf, 2016-11-22 23:11:50

How to tell Postgres to sort results by the first matching column?

Good day dear!
There is a query like: SELECT 1 AS a, 2 AS a ORDER BY a. In which there are two columns named "a". When trying to execute it, it gets "... 'a' is ambigous ..." when sorted. Can you please tell me how to force the result to be sorted by the first column in the results?
PS Yes, I understand that it would be more correct to create an alias, specify a table.column , and so on, but the question is that we have two columns with the same name, and we need to sort by the first one (by the first column with the name "a ", and not on the first column at all).

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question