Re: [GENERAL] multi-column aggregates

2006-03-13 Thread Chris Kratz
Hello Bruno, Yes, we have used the distinct on operator in the past and that works quite well when you have a single ordering column or multiples which don't contradict each other. The joins would work, but I was hoping for a simpler solution as this is sql generated from a general purpose

Re: [GENERAL] multi-column aggregates

2006-03-13 Thread Chris Kratz
Hello Berend, Thanks for the reply. Yes, subselects would work very well and in some ways are more elegant then the hand waving we had to do to get the multi-column aggregates to work. The reason we moved away from the subselects is that the queries tend to be quite complex and all of the

Re: [GENERAL] multi-column aggregates

2006-03-13 Thread Chris Kratz
On Thursday 09 March 2006 02:18 pm, Merlin Moncure wrote: Chris Kratz wrote: Well for anyone else who may be interested in doing something similar, here is what we did. It does require typecasting going into the functions, composite types and using the dot notation to get the value back

Re: [GENERAL] multi-column aggregates

2006-03-13 Thread Merlin Moncure
I have to confess I'm not real familiar with rowwise comparisons. Would this work when you have a large number of rows. For example, give me all individuals and their income their favorite TV Show the first and last times they were contacted. ie | Person | First Favorite | Last Favorite |

Re: [GENERAL] multi-column aggregates

2006-03-13 Thread Tom Lane
Chris Kratz [EMAIL PROTECTED] writes: Thanks for the reply. Yes, subselects would work very well and in some ways are more elegant then the hand waving we had to do to get the multi-column aggregates to work. BTW, there is not any fundamental reason why we can't support aggregate functions

Re: [GENERAL] multi-column aggregates

2006-03-13 Thread Chris Kratz
On Monday 13 March 2006 03:21 pm, Tom Lane wrote: Chris Kratz [EMAIL PROTECTED] writes: Thanks for the reply. Yes, subselects would work very well and in some ways are more elegant then the hand waving we had to do to get the multi-column aggregates to work. BTW, there is not any

Re: [GENERAL] multi-column aggregates

2006-03-13 Thread Berend Tober
Tom Lane wrote: Chris Kratz [EMAIL PROTECTED] writes: Thanks for the reply. Yes, subselects would work very well and in some ways are more elegant then the hand waving we had to do to get the multi-column aggregates to work. BTW, there is not any fundamental reason why we can't

[GENERAL] multi-column aggregates

2006-03-09 Thread Chris Kratz
Hello All, Is there any way in postgres to have an aggregate that uses input from two columns without using composite types? The example we are working on is a first or last aggregate which requires a data value and a date column. The result would be to find the latest date within the group

Re: [GENERAL] multi-column aggregates

2006-03-09 Thread Tom Lane
Chris Kratz [EMAIL PROTECTED] writes: Is there any way in postgres to have an aggregate that uses input from two columns without using composite types? No. regards, tom lane ---(end of broadcast)--- TIP 9: In versions

Re: [GENERAL] multi-column aggregates

2006-03-09 Thread Chris Kratz
Thanks Tom, Well for anyone else who may be interested in doing something similar, here is what we did. It does require typecasting going into the functions, composite types and using the dot notation to get the value back out of the composite object returned. But it works. This is what we

Re: [GENERAL] multi-column aggregates

2006-03-09 Thread Merlin Moncure
Chris Kratz wrote: Well for anyone else who may be interested in doing something similar, here is what we did. It does require typecasting going into the functions, composite types and using the dot notation to get the value back out of the composite object returned. But it works. This is

Re: [GENERAL] multi-column aggregates

2006-03-09 Thread Berend Tober
I may not fully understand your situation but SELECT distinct grouping, (SELECT integer_column FROM test.test_agg_last WHERE grouping=t1.grouping ORDER BY cur_date DESC LIMIT 1) AS last_int, (SELECT integer_column FROM test.test_agg_last WHERE grouping=t1.grouping ORDER BY cur_date ASC LIMIT

Re: [GENERAL] multi-column aggregates

2006-03-09 Thread Bruno Wolff III
On Thu, Mar 09, 2006 at 12:56:21 -0500, Chris Kratz [EMAIL PROTECTED] wrote: Hello All, Is there any way in postgres to have an aggregate that uses input from two columns without using composite types? The example we are working on is a first or last aggregate which requires a data