Re: [GENERAL] HAVING QUESTION
От | Bruce Momjian |
---|---|
Тема | Re: [GENERAL] HAVING QUESTION |
Дата | |
Msg-id | 199911031817.NAA25326@candle.pha.pa.us обсуждение исходный текст |
Ответ на | HAVING QUESTION (Alexander Barkov <bar@izhcom.ru>) |
Список | pgsql-general |
[Charset koi8-r unsupported, filtering to ASCII...] > > Hi! > > > How can I refer the calculated field in HAVING clause. > > This work in MySQL: > > SELECT some_expression as field1, ... > FROM tablename > GROUP BY ... > HAVING field1>0; > > PostgreSQL gives error "Attribute 'field1' not found". Worked here in development tree: select state as test, count(*) from friends group by test having count(*) > 1\g test|count ----+----- MA | 2 NJ | 2 (2 rows) I think your problem is that field1 is not an aggregate or if it is, you may need to repeat the aggregate in the having. -- 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, Pennsylvania 19026
В списке pgsql-general по дате отправления: