correlated subquery - Mailing list pgsql-hackers

From Bruce Momjian
Subject correlated subquery
Date
Msg-id 199912292236.RAA13960@candle.pha.pa.us
Whole thread Raw
Responses Re: [HACKERS] correlated subquery
Re: [HACKERS] correlated subquery
List pgsql-hackers
Is this a good example of a required correlated subquery:
SELECT f1.firstname, f1.lastname, f1.ageFROM friends f1WHERE age = (             SELECT MAX(age)             FROM
friendsf2             WHERE f1.state = f2.state            )ORDER BY firstname, lastname
 

It finds the oldest person in each state.  HAVING can't do that, right?

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-hackers by date:

Previous
From: wieck@debis.com (Jan Wieck)
Date:
Subject: Re: [HACKERS] Index corruption
Next
From: Adriaan Joubert
Date:
Subject: Re: [HACKERS] Index corruption