From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
---|---|
To: | john-paul delaney <jp(at)justatest(dot)com> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Query combination query. (fwd) |
Date: | 2005-02-22 15:01:28 |
Message-ID: | 20050222150128.GG22550@wolff.to |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Tue, Feb 22, 2005 at 15:54:47 +0100,
john-paul delaney <jp(at)justatest(dot)com> wrote:
>
> Given Sean's answer above, I then managed the simple part to get the author
> name from another table, but was stumped when I thought it
> would be better to return the created date of the last message (having the same
> topic_id) rather than the first one. The last message can be found in
> either of two ways:
> (1) the latest 'created' for a topic_id or
> (2) the highest 'topic_seq' number for a topic id.
>
> I've failed miserably in my attempts - any enlightenment greatly appreciated.
The standard way to do this is to use the max function and select the
row that matches this value.
However the nonstandard DISTINCT ON construct is a better way to go if
you don't need to be portable.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2005-02-22 15:20:55 | Re: Function with record type as argument |
Previous Message | john-paul delaney | 2005-02-22 14:54:47 | Re: Query combination query. (fwd) |