Re: [GENERAL] Ordering of records in group by not possible

2006-04-26 Thread Tom Lane
Alban Hertroys <[EMAIL PROTECTED]> writes: > Ordering the data before aggregating should do the trick though, but > you'll need to order your records in the subquery. Something like this, > I think: > Select a, aggregate(b) > from ( > select a, b > from c > order by a,b > ) d >

Re: [GENERAL] Ordering of records in group by not possible

2006-04-26 Thread Alban Hertroys
Chris Kratz wrote: On Wednesday 26 April 2006 10:30 am, you wrote: Hello Alban, The point is that the aggregates we are working on in our application are order sensitive. One common example of order sensitive aggregates are the first and last aggregate functions found in some other databases.

Re: [GENERAL] Ordering of records in group by not possible

2006-04-26 Thread Chris Kratz
On Wednesday 26 April 2006 11:19 am, Ludwig Isaac Lim wrote: > Hi: > > You could order by "column 2" if you want to order on the > > results on > > your aggregate: > > Select a, aggregate(b) > > from c > > group by a > > order by a,2 > > another alternative is : > >select a , ag

Re: [GENERAL] Ordering of records in group by not possible

2006-04-26 Thread Chris Kratz
On Wednesday 26 April 2006 10:30 am, you wrote: > Chris Kratz wrote: > > Hello all, > > > > I wanted to verify what we are seeing. > > > > Select a, aggregate(b) > > from c > > group by a > > order by a,b > > That's a rather odd query... Values in b aren't available to order by, > as they have been

Re: [GENERAL] Ordering of records in group by not possible

2006-04-26 Thread Ludwig Isaac Lim
Hi: > You could order by "column 2" if you want to order on the > results on > your aggregate: > Select a, aggregate(b) > from c > group by a > order by a,2 > another alternative is : select a , aggregrate(b) as from c group by a order by a, e.g. s

Re: [GENERAL] Ordering of records in group by not possible

2006-04-26 Thread Alban Hertroys
Chris Kratz wrote: Hello all, I wanted to verify what we are seeing. Select a, aggregate(b) from c group by a order by a,b That's a rather odd query... Values in b aren't available to order by, as they have been aggregated. There is no relation to the values in b and the values in your resu

Re: [GENERAL] Ordering of records in group by not possible

2006-04-26 Thread Martijn van Oosterhout
On Wed, Apr 26, 2006 at 09:19:41AM -0400, Chris Kratz wrote: > Hello all, > > I wanted to verify what we are seeing. > Select a, aggregate(b) > from c > group by a > order by a,b > > Is not accepted by postgres. This will only work if you order by a. But, > this means that the records that ar

[GENERAL] Ordering of records in group by not possible

2006-04-26 Thread Chris Kratz
Hello all, I wanted to verify what we are seeing. Select a, aggregate(b) from c group by a order by a,b Is not accepted by postgres. This will only work if you order by a. But, this means that the records that are grouped are processed in no apparent order. We have some custom aggregate fun