Re: [GENERAL] (Hopefully stupid) select question.

2011-01-24 Thread Fredric Fredricson
On 01/24/2011 05:02 PM, A.M. wrote: On Jan 24, 2011, at 10:50 AM, Fredric Fredricson wrote: I have been fighting with a select and can find no satisfactory solution. Simplified version of the problem: A table that, in reality, log state changes to an object (represented as a row in another t

Re: [GENERAL] (Hopefully stupid) select question.

2011-01-24 Thread Fredric Fredricson
On 01/24/2011 04:56 PM, Tom Lane wrote: Fredric Fredricson writes: ... Now I want the latest "someData" for each "ref" like: The best solution I could find depended on the fact that serial is higher for higher dates. I do not like that because if that is true, it is an indirect way to get the d

Re: [GENERAL] (Hopefully stupid) select question.

2011-01-24 Thread A.M.
On Jan 24, 2011, at 10:50 AM, Fredric Fredricson wrote: > I have been fighting with a select and can find no satisfactory solution. > > Simplified version of the problem: > > A table that, in reality, log state changes to an object (represented as a > row in another table): > > CREATE TABLE t

Re: [GENERAL] (Hopefully stupid) select question.

2011-01-24 Thread Tom Lane
Fredric Fredricson writes: > ... Now I want the latest "someData" for each "ref" like: > The best solution I could find depended on the fact that serial is > higher for higher dates. I do not like that because if that is true, it > is an indirect way to get the data and could possibly, in the f

[GENERAL] (Hopefully stupid) select question.

2011-01-24 Thread Fredric Fredricson
I have been fighting with a select and can find no satisfactory solution. Simplified version of the problem: A table that, in reality, log state changes to an object (represented as a row in another table): CREATE TABLE t ( id SERIAL UNIQUE, ref INTEGER, -- Reference to a row in anoth