Most recent row

From: Gary Stainburn <gary(dot)stainburn(at)ringways(dot)co(dot)uk>
To: pgsql-sql(at)postgresql(dot)org
Subject: Most recent row
Date: 2017-05-05 08:25:04
Message-ID: 201705050925.04194.gary.stainburn@ringways.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

This question has been asked a few times, and Google returns a few different
answers, but I am interested people's opinions and suggestions for the *best*
wat to retrieve the most recent row from a table.

My case is:

create table people (
p_id serial primary key,
......
);

create table assessments (
p_id int4 not null references people(p_id),
as_timestamp timestamp not null,
......
);

select p.*, (most recent) a.*
from people p, assessments a
..
;

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Karsten Hilbert 2017-05-05 08:32:21 Re: Most recent row
Previous Message Hector Vass 2017-04-20 22:04:01 Re: Please advice on query optimization