Bug in GROUP BY for INSERT

From: Pushkar Piggott <pkp(at)citr(dot)com(dot)au>
To: pgsql-sql(at)postgresql(dot)org
Cc: symons(at)citr(dot)com(dot)au (Anthony Symons)
Subject: Bug in GROUP BY for INSERT
Date: 1998-08-26 23:34:41
Message-ID: 199808262334.JAA07554@guava.citr.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

The following is surely not the intended operation:

<pkp(at)cooloola> createdb pkptest
<pkp(at)cooloola> psql pkptest
Welcome to the POSTGRESQL interactive sql monitor:
Please read the file COPYRIGHT for copyright terms of POSTGRESQL

type \? for help on slash commands
type \q to quit
type \g or terminate with semicolon to execute query
You are currently connected to the database: pkptest

pkptest=> CREATE TABLE a_foo (a_Index int4,
pkptest-> bar int4);
CREATE
pkptest=> INSERT INTO a_foo
pkptest-> VALUES (1, 1);
INSERT 252074 1
pkptest=> INSERT INTO a_foo
pkptest-> VALUES (2, 1);
INSERT 252075 1
pkptest=> CREATE TABLE b_foo (b_Index int4,
pkptest-> count int4);
CREATE
pkptest=> INSERT INTO b_foo
pkptest-> SELECT a_Index, COUNT(*)
pkptest-> FROM a_foo
pkptest-> GROUP BY a_Index;
ERROR: The field being grouped by must appear in the target list
pkptest=> INSERT INTO b_foo
pkptest-> SELECT a_Index, COUNT(*)
pkptest-> FROM a_foo
pkptest-> GROUP BY b_Index;
INSERT 0 2

cheers
Pushkar
--
------------------------------------------------------------------------------
Dr Pushkar Piggott |
| Phone: +61-7-3259-2369
CiTR Pty Ltd | Fax: +61-7-3259-2259
John Oxley Centre |
339 Coronation Drive | Email: p(dot)piggott(at)citr(dot)com(dot)au
MILTON |
QLD 4064 AUSTRALIA | Postal: PO Box 1643
------------------------------------------------------------------------------

Browse pgsql-sql by date

  From Date Subject
Next Message Pushkar Piggott 1998-08-27 01:00:15 Another bug in GROUP BY for INSERT
Previous Message Ian Johnston 1998-08-26 20:15:06 How do I ???