| From: | "Markus Bertheau" <twanger(at)eudoramail(dot)com> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Cc: | bertheau(at)bab24(dot)de |
| Subject: | select tbl1.attr1, number of tuples where tbl2.attr1=tbl1.attr1 |
| Date: | 2001-06-22 12:06:32 |
| Message-ID: | EDADHKGMDOLIACAA@shared1-mail.whowhere.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | DI Hasenöhrl | 2001-06-22 12:14:39 | CAST Problem: Difference between insert a tuple in a table by function and by datasheet |
| Previous Message | Alex Pilosov | 2001-06-22 11:57:10 | Re: [SQL] distinguishing different database connections |