From: Markus Bertheau <twanger@eudoramail.com>
To: pgsql-sql@postgresql.org
Cc: bertheau@bab24.de
Subject: select tbl1.attr1, number of tuples where tbl2.attr1=tbl1.attr1
Date: Fri, 22 Jun 2001 13:06:32 +0100
Message-ID: <EDADHKGMDOLIACAA@shared1-mail.whowhere.com> (raw)
Hey,
I have three tables.
table persons
{
login,
person_id UNIQUE
}
table views
{
person_id,
timestamp
}
table partners
{
person_id UNIQUE,
domain
}
for each tuple in partners i want to know the number of tuples in views with the same person_id.
I tried sth like
select partners.person_id, count(views.person_id) from partners, views where views.person_id = partners.person_id
but it said, partners.person_id must be grouped.
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.
How can I do that?
TIA,
Markus Bertheau
Cenes Data GmbH
Join 18 million Eudora users by signing up for a free Eudora Web-Mail account at http://www.eudoramail.com
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: twanger@eudoramail.com, bertheau@bab24.de
Subject: Re: select tbl1.attr1, number of tuples where tbl2.attr1=tbl1.attr1
In-Reply-To: <EDADHKGMDOLIACAA@shared1-mail.whowhere.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