Actually, it can be done with a temporary table, as I have already told
Cristi (short for Cristian, btw :) ) like this:
SELECT m1, max (ore) AS mx, sum(ore) AS sm INTO TEMPORARY tmp FROM xxx GROUP
SELECT co,co1,n1,l1,tmp.m1,sm FROM xxx JOIN tmp ON xxx.m1=tmp.m1 AND
xxx.ore=tmp.mx ORDER BY tmp.m1 asc;
Ain't I a stinker? :)
I have to ask you guys if you know if this way is faster than making a
script that computes the max and the sum while parsing the table. Because
that join could slow things down, I guess...
The reason for this post (besides that of bragging) is that people bump into
similar problems all the time.
Like finding the values in the row that has one value maximum. You can't do
"select a,b,c,d from table where d=max(d) group by c";
The above example is my solution to it. I invite you to find other
solutions, maybe more ellegant.
In response to
- Re: sql at 2004-06-24 18:20:43 from Manfred Koizar
pgsql-novice by date
|Next:||From: Andrew Hammond||Date: 2004-06-25 15:37:52|
|Subject: Re: sql|
|Previous:||From: A Palmblad||Date: 2004-06-24 20:10:46|
|Subject: Re: database corruption|