Re: [SQL] Arrays and count()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mr M Pacey <M(dot)Pacey(at)liverpool(dot)ac(dot)uk>
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] Arrays and count()
Date: 1999-04-27 15:07:32
Message-ID: 8505.925225652@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Mr M Pacey <M(dot)Pacey(at)liverpool(dot)ac(dot)uk> 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

Browse pgsql-sql by date

  From Date Subject
Next Message José Soares 1999-04-27 15:18:47 Re: [SQL] substring
Previous Message Tom Lane 1999-04-27 14:36:43 Re: [SQL] substring