I don't understand: is my question not clear, stupid, or you guys just
don't like me? ;)
Original Message
Subject:[Fwd: Re: [GENERAL] return MAX and when it happened]
Date: Fri, 21 Nov 2008 08:48:44 -0600
From: Scara Maccai <[EMAIL PROTECTED]>
To
Can someone answer me? Or do I have to ask this in the hackers list?
I don't get from the docs: do I have to call
get_call_result_type(fcinfo, NULL, &tupdesc)
every time?
I mean: the only example I've found about returning Composite Types
talks about returning sets as well (34.9.10. Returni
Sam Mason wrote:
On Wed, Nov 19, 2008 at 05:06:14PM -0600, Scara Maccai wrote:
I think I wrote it, but there's something I don't get from the docs: do
I have to call
get_call_result_type(fcinfo, NULL, &tupdesc)
I've always tried to stay away from C level extensions so far! How
many
On Wed, Nov 19, 2008 at 05:06:14PM -0600, Scara Maccai wrote:
> Sam Mason wrote:
> >The custom aggregate sounds the
> >most elegant, it's just annoying that it's so much fiddling to get it
> >all working to start with
> Thanks.
>
> I think I wrote it, but there's something I don't get from the doc
Sam Mason wrote:
The custom aggregate sounds the
most elegant, it's just annoying that it's so much fiddling to get it
all working to start with
Thanks.
I think I wrote it, but there's something I don't get from the docs: do
I have to call
get_call_result_type(fcinfo, NULL, &tupdesc)
every
On Wed, Nov 19, 2008 at 10:10:08AM -0600, Scara Maccai wrote:
> Sam Mason wrote:
> >Do you really want the SUM of num1 and num2, because that makes it more
> >fiddly and would be where having MAX accept a record/tuple would be
> >best. If you don't, maybe something like:
> >
> > SELECT DISTINCT O
Sam Mason wrote:
Do you really want the SUM of num1 and num2, because that makes it more
fiddly and would be where having MAX accept a record/tuple would be
best. If you don't, maybe something like:
SELECT DISTINCT ON (date_trunc('day', mydate))
date_trunc('day', mydate), num, num1+num2
On Wed, Nov 19, 2008 at 09:35:34AM -0600, Scara Maccai wrote:
> Well you guys are right; the problem is that the query is actually more
> complex, I tried to simplify it for the question, but ended up with a
> trivial question...
always a problem with simplification, I've done the same far too o
Sam Mason wrote:
Why not just do:
SELECT * FROM mytab
ORDER BY num, mydate
LIMIT 1;
If you're trying to do more complicated things, DISTINCT ON may be more
useful.
Well you guys are right; the problem is that the query is actually more
complex, I tried to simplify it for the questio
On Wed, Nov 19, 2008 at 08:47:57AM -0600, Scara Maccai wrote:
> CREATE TABLE mytab
> (
> num integer,
> mydate timestamp
> );
>
> and I want to find MAX(num) and the "mydate" where it first happened.
>
> I guess I could use
>
> select * from mytab where num = (select MAX(num) from mytab)
Hi Scara,
This should work just fine:
select num, min(mydate) from mytab group by num order by num desc limit
1;
If you have an index on 'num' it will also be fast.
Cheers,
Csaba.
On Wed, 2008-11-19 at 08:47 -0600, Scara Maccai wrote:
> Hi all,
>
> suppose I have a table like:
>
> CREATE TAB
Hi all,
suppose I have a table like:
CREATE TABLE mytab
(
num integer,
mydate timestamp
);
and I want to find MAX(num) and the "mydate" where it first happened.
I guess I could use
select * from mytab where num = (select MAX(num) from mytab) order by
mydate limit 1;
but that would sc
12 matches
Mail list logo