order by
От | Luca Ferrari |
---|---|
Тема | order by |
Дата | |
Msg-id | CAKoxK+5uLxLGo3CSeYX41mxiATbUgQ3P-KtU2FrB5X7ju1=QcQ@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: order by Re: order by |
Список | pgsql-general |
Hi all, this could be trivial, but I found as an accident the following: pgbench=> create table t as select v from generate_series( 1, 2 ) v; SELECT 2 pgbench=> select * from t order by foo; ERROR: column "foo" does not exist LINE 1: select * from t order by foo; ^ pgbench=> select * from t order by t; v --- 1 2 (2 rows) The ORDER BY rejects non existent columns (right) but accepts the table itself as an ordering expression. Reading here <https://www.postgresql.org/docs/12/sql-select.html#SQL-ORDERBY> I cannot really understand why it is working and which kind of ordering it is applying at all, I suspect the same ordering as without ORDER BY at all. Any hint? Just for the record, seems that supplying another table name is rejected too, as I would expect: pgbench=> select * from t order by pgbench_accounts; ERROR: column "pgbench_accounts" does not exist LINE 1: select * from t order by pgbench_accounts; Thanks, Luca
В списке pgsql-general по дате отправления: