pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Hartwig <daveh@insightdist.com>
To: Howie <caffeine@toodarkpark.org>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] count(*) and group by's...
Date: Tue, 20 Oct 1998 13:39:04 -0400
Message-ID: <362CCAB8.480ECB64@insightdist.com> (raw)
References: <Pine.LNX.3.96.981020125545.10567E-100000@brap-eth0.toodarkpark.org>

SELECT types.type, hosts.hostname, types.batch, count(codes.code)
        FROM hosts,types,codes
WHERE hosts.client=3 AND
    hosts.client=types.client AND
    types.type=codes.type
GROUP BY types.type, hosts.hostname, types.batch
--                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
ORDER BY types.batch;

-- All columns in the target (projection) must be either an aggregate
function or grouped by


Howie wrote:

> I give up.  I'm trying to get a count of one table joining with another,
> but Postgres ( 6.3.2 ) doesnt like me.
>
> SELECT types.type,hosts.hostname,types.batch,count(codes.code) FROM
> hosts,types,codes WHERE hosts.client=3 AND hosts.client=types.client AND
> types.type=codes.type GROUP BY types.type ORDER BY types.batch;
>
> returns:
>
> ERROR:  parser: illegal use of aggregates or non-group column in target
> list
>
> in fact, trying to do any join across types and codes results in an
> illegal use/non-group column.  types.type is primary,
> codes.type+codes.code is primary.
>
> ---
> Howie <caffeine@toodarkpark.org>   URL: http://www.toodarkpark.org
>         "Oh my god, they killed init!  YOU BASTARDS!"






view thread (2+ messages)

Message-ID: <362CCAB8.480ECB64@insightdist.com>
Permalink:  ../362CCAB8.480ECB64@insightdist.com/
Also on:    postgresql.org/message-id/362CCAB8.480ECB64@insightdist.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: daveh@insightdist.com, caffeine@toodarkpark.org
  Subject: Re: [SQL] count(*) and group by's...
  In-Reply-To: <362CCAB8.480ECB64@insightdist.com>
  References: <Pine.LNX.3.96.981020125545.10567E-100000@brap-eth0.toodarkpark.org> <362CCAB8.480ECB64@insightdist.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox