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