Is this a good example of a required correlated subquery:
SELECT f1.firstname, f1.lastname, f1.age
FROM friends f1
WHERE age = (
SELECT MAX(age)
FROM friends f2
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(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026