Re: How to select the last value/row? - Mailing list pgsql-sql

From Tom Lane
Subject Re: How to select the last value/row?
Date
Msg-id 1218123.1688659921@sss.pgh.pa.us
Whole thread Raw
In response to Re: How to select the last value/row?  (Shaozhong SHI <shishaozhong@gmail.com>)
List 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 by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: How to select the last value/row?
Next
From: Shaozhong SHI
Date:
Subject: How do Exception, do nothing and carry on