using the aggregate function max() - Mailing list pgsql-sql

From John Fabiani
Subject using the aggregate function max()
Date
Msg-id 201109221949.20671.johnf@jfcomputer.com
Whole thread Raw
Responses Re: using the aggregate function max()
Re: using the aggregate function max()
List pgsql-sql
Hi,
I need a little help understanding how to attack this problem.  

I need to find the max(date) of a field but I need that value later in my 
query.

If I
select max(x.date_field) as special_date from (select date_field) from table 
where ...)x 

I get one row and column.

But now I want to use that field in the rest of the query

select y.*,  max(x.date_field) as special_date from (select date_field) from 
table where ...)x  
from aTable y where y.somefield = special_date.

The above only returns one row and one column the "special_date."

How can I use the aggregate field "special_date" in the rest of the query?  Or 
is there some other way?

Johnf


pgsql-sql by date:

Previous
From: Amar Dhole
Date:
Subject: Re: handling duplicate row exception
Next
From: David Johnston
Date:
Subject: Re: using the aggregate function max()