Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [206.210.65.6]) by hub.org (8.9.3/8.9.1) with ESMTP id LAA09110 for ; Tue, 27 Apr 1999 11:08:27 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.sss.pgh.pa.us (8.9.1/8.9.1) with ESMTP id LAA08507; Tue, 27 Apr 1999 11:07:33 -0400 (EDT) To: Mr M Pacey cc: pgsql-sql@postgreSQL.org Subject: Re: [SQL] Arrays and count() In-reply-to: Your message of Tue, 27 Apr 1999 15:04:24 +0100 <3725C3E8.18B0@liverpool.ac.uk> Date: Tue, 27 Apr 1999 11:07:32 -0400 Message-ID: <8505.925225652@sss.pgh.pa.us> From: Tom Lane Mr M Pacey writes: > select sentence.tags[1], count (*) from sentence group by > sentence.tags[1]; > Which fails to parse. Yes, I get 'Illegal use of aggregates or non-group column in target list' with current sources. Without having looked, my guess is that the system is too dumb to realize that the same array element is being named at both places (ie, it's not exploiting the fact that the subscripts are constant). Not sure how hard this might be to fix. > select count (sentence.tags[1]) from sentence; > PQexec() -- Request was sent to backend, but backend closed the channel > before responding. Still crashes in 6.5-current :-(. Will look into it. As a workaround, you could probably select the tag data into a temporary table and then do the group by on the temp table... regards, tom lane