Re: How to select the last value/row?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: How to select the last value/row?
Дата
Msg-id 1218123.1688659921@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: How to select the last value/row?  (Shaozhong SHI <shishaozhong@gmail.com>)
Список pgsql-sql
Shaozhong SHI <shishaozhong@gmail.com> writes:
> How about
> ID
> 5
> 4
> 3
> 3
> 2
> 3

> The last is 3.

You need to reorient your thinking.  In SQL, row sets are unordered sets
of values --- this is not a Postgres deficiency, it's a fundamental tenet
of the relational data model.  If you want some kind of ordering, you have
to express that by an ORDER BY clause, which means you need something
within the data that corresponds to what you want the ordering to be.
Your example above is basically nonsense from the standpoint of SQL.

            regards, tom lane



В списке pgsql-sql по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: How to select the last value/row?
Следующее
От: Shaozhong SHI
Дата:
Сообщение: How do Exception, do nothing and carry on