Arrays and count ()

From: Mr M Pacey <M(dot)Pacey(at)liverpool(dot)ac(dot)uk>
To: pgsql-sql(at)postgresql(dot)org
Subject: Arrays and count ()
Date: 1999-04-27 13:48:36
Message-ID: 3725C034.7DFF@liverpool.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I'm having difficulties formulating what I thought was a simple
query in 6.3.2. I have a table defined like this:

create table sentence
(
typenum int4,
wordpos int4,
words text[],
tags text[]
);

What I'd like to do is, e.g. select all instances of tags[1] and
display the frequency values for each unique (distinct) entry.

The query I tried was:

select sentence.tags[1], count (*) from sentence group by
sentence.tags[1];

Which fails to parse.

Trying to work backwards I try constructing a related command:

select count (sentence.tags[1]) from sentence;

And am treated to the error message:

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.

Is this a bug, or am I completely failing to understand one or more
of the concepts involved here?

Mike Pacey.

P.S. Please cc any reply directly to me, as I'm not currently subbed to
the list.

Browse pgsql-sql by date

  From Date Subject
Next Message Mr M Pacey 1999-04-27 14:04:24 Arrays and count()
Previous Message José Soares 1999-04-27 13:01:32 Re: [SQL] substring