From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
---|---|
To: | Mike Nolan <nolan(at)gw(dot)tssi(dot)com> |
Cc: | pgsql general list <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: 7.4, 'group by' default ordering? |
Date: | 2004-01-08 20:12:01 |
Message-ID: | 20040108201201.GA19740@wolff.to |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Jan 08, 2004 at 13:42:33 -0600,
Mike Nolan <nolan(at)gw(dot)tssi(dot)com> wrote:
> I notice that 7.4 doesn't do default ordering on a 'group by', so you have
> to throw in an 'order by' clause to get the output in ascending group order.
>
> Is this something that most RDB's have historically done (including PG prior
> to 7.4) but isn't really part of the SQL standard?
That is because group by is often done with a sort, so rows would naturally
be in that order. If there isn't an order by clause, the set of return
rows can be in any order.
> On a mostly unrelated topic, does the SQL standard indicate whether NULL
> should sort to the front or the back? Is there a way to force it to
> one or the other independent of whether the order by clause uses ascending or
> descending order?
In SQL for Smarties, Joe Ceclko says that either NULLs should all be first
or all be last (independent of whether the sort is ascending or descending).
There was also some discussion on how the order is constrained if the sort
is on multiple columns where the value of the first column is NULL, but the
values of other columns are not. I don't have the book here with me now,
but I think the result of the discussion was that within rows with a NULL
value for the first column, they should be sorted by the values in the
later columns.
From | Date | Subject | |
---|---|---|---|
Next Message | David Garamond | 2004-01-08 20:45:39 | int8 version of NUMERIC? |
Previous Message | Holger Marzen | 2004-01-08 20:04:35 | Re: Compile problem on old Debian Linux with glibc 2.0.7 |