HAVING clause

From: "Thomas G(dot) Lockhart" <lockhart(at)alumni(dot)caltech(dot)edu>
To: Stefan Simkovics <ssimkovi(at)rainbow(dot)studorg(dot)tuwien(dot)ac(dot)at>
Cc: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>, Postgres Hackers List <hackers(at)postgresql(dot)org>
Subject: HAVING clause
Date: 1998-04-08 14:18:10
Message-ID: 352B8722.F324CF6C@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Send the bug report to here and Stefan (he is on the TODO list).
> Let's see if he can fix it.

Hi Stefan. I ran across some funny behavior with the HAVING clause:

-- try a having clause in the wrong order (OK, my mistake :)
postgres=> select x.x, count(y.i) from t x, t y
group by x.x having x.x = 'four';
PQexec() -- Request was sent to backend, but backend closed
the channel before responding. This probably means the backend
terminated abnormally before or while processing the request.

<start over>
-- works better when it is a good query...
postgres=> select x.x, count(y.i) from t x, t y
group by x.x having count(y.i) = 40;
x |count
----+-----
four| 40
(1 row)

Table is defined below...

- Tom

postgres=> create table t (x text, i int);

<populate the table; one entry for 'one', two for 'two', etc>

postgres=> select x, i, count(i) from t group by x, i;
x |i|count
-----+-+-----
four |4| 4
one |1| 1
three|3| 3
two |2| 2
(4 rows)

Browse pgsql-hackers by date

  From Date Subject
Next Message Ronald Baljeu 1998-04-08 14:39:53 Is this legal???
Previous Message Maurice Gittens 1998-04-08 08:56:50 pg_type populated incorrectly in some cases?