From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org> |
Subject: | Using aggregate in HAVING |
Date: | 1999-12-29 19:51:19 |
Message-ID: | 199912291951.OAA08646@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
How would I get all friends greater than the average age?
CREATE TABLE friends (
firstname CHAR(15),
lastname CHAR(20),
age INTEGER)
SELECT firstname, lastname
FROM friends
HAVING age >= AVG(age)
ERROR: Attribute friends.firstname must be GROUPed or used in an
aggregate function
This fails too:
SELECT firstname, lastname
FROM friends
WHERE age >= AVG(age)
ERROR: Aggregates not allowed in WHERE clause
This fails. I am stumped.
--
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
From | Date | Subject | |
---|---|---|---|
Next Message | Mike Mascari | 1999-12-29 20:17:28 | Re: [HACKERS] Using aggregate in HAVING |
Previous Message | Bruce Momjian | 1999-12-29 19:09:00 | Re: [HACKERS] Index corruption |