Re: Subquery to select max(date) value

From: Matt Zagrabelny <mzagrabe(at)d(dot)umn(dot)edu>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Subquery to select max(date) value
Date: 2019-02-12 22:55:01
Message-ID: CAOLfK3W7w_O8A4zCeZQpRJPSHLzzYx00xRQ5cJ95TORLfKc7pQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hey Rich,

On Tue, Feb 12, 2019 at 4:24 PM Rich Shepard <rshepard(at)appl-ecosys(dot)com>
wrote:

> The query is to return the latest next_contact date for each person. Using
> the max() aggregate function and modeling the example of lo_temp on page 13
> of the rel. 10 manual I wrote this statement:
>

I use DISTINCT ON and ORDER BY to get the single latest value from a table
with multiple date entries:

https://stackoverflow.com/questions/9795660/postgresql-distinct-on-with-different-order-by

HTH,

-m

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2019-02-12 22:58:42 Re: Subquery to select max(date) value
Previous Message Rich Shepard 2019-02-12 22:48:45 Re: Subquery to select max(date) value