pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: twanger@eudoramail.com
Cc: pgsql-sql@postgresql.org
Cc: bertheau@bab24.de
Subject: Re: select tbl1.attr1, number of tuples where tbl2.attr1=tbl1.attr1
Date: Fri, 22 Jun 2001 09:54:27 -0400
Message-ID: <3360.993218067@sss.pgh.pa.us> (raw)
In-Reply-To: <EDADHKGMDOLIACAA@shared1-mail.whowhere.com>
References: <EDADHKGMDOLIACAA@shared1-mail.whowhere.com>

"Markus Bertheau" <twanger@eudoramail.com> writes:
> Then i tried
> select partners.person_id, count(views.person_id) from partners, views where views.person_id = partners.person_id group by views.person_id

> but this gave very strange results which are definitely not what i wanted.

I think you mistyped, because that query will also fail:

regression=# create table views (person_id int, timestamp timestamp);
CREATE
regression=# create table partners (person_id int UNIQUE, domain text);
NOTICE:  CREATE TABLE/UNIQUE will create implicit index 'partners_person_id_key' for table 'partners'
CREATE
regression=# select partners.person_id, count(views.person_id)
regression-# from partners, views where views.person_id = partners.person_id
regression-# group by views.person_id;
ERROR:  Attribute partners.person_id must be GROUPed or used in an aggregate function

How about showing us what you *really* did?

			regards, tom lane



view thread (2+ messages)

Message-ID: <3360.993218067@sss.pgh.pa.us>
Permalink:  ../3360.993218067@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3360.993218067@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, twanger@eudoramail.com, bertheau@bab24.de
  Subject: Re: select tbl1.attr1, number of tuples where tbl2.attr1=tbl1.attr1
  In-Reply-To: <3360.993218067@sss.pgh.pa.us>

* 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