From: | David Hartwig <daveh(at)insightdist(dot)com> |
---|---|
To: | Howie <caffeine(at)toodarkpark(dot)org> |
Cc: | pgsql-sql(at)postgreSQL(dot)org |
Subject: | Re: [SQL] count(*) and group by's... |
Date: | 1998-10-20 17:39:04 |
Message-ID: | 362CCAB8.480ECB64@insightdist.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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(at)toodarkpark(dot)org> URL: http://www.toodarkpark.org
> "Oh my god, they killed init! YOU BASTARDS!"
From | Date | Subject | |
---|---|---|---|
Next Message | Mark Wilson | 1998-10-21 13:52:04 | Large Object Interface |
Previous Message | Howie | 1998-10-20 16:59:49 | count(*) and group by's... |