From: | "Eric L(dot) Blevins" <eblevins(at)insight(dot)rr(dot)com> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Help with SQL |
Date: | 2002-10-16 18:26:11 |
Message-ID: | 009c01c27541$83bf46b0$0201a8c0@Gateway |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
I'm new to postgres.
I've got 2 SQL statements I would like to combine into one.
I think I need to use a sub select or join I am not sure.
Any help would be appreciated!
statement 1: SELECT uid, count(uid) FROM triangulated WHERE uid != 'anonymus' AND uid
!= 'anonymous' AND uid != '' GROUP BY uid ORDER BY count DESC LIMIT 10;
that returns something like this:
uid | count
-------------+-------
eblevins | 1179
DaClyde | 398
Drew | 30
zombiechick | 3
(4 rows)
statement 2: SELECT uid, count(uid) FROM points WHERE uid != 'anonymus' AND uid !=
'anonymous' AND uid != '' GROUP BY uid ORDER BY count DESC LIMIT 10;
that returns something like this:
uid | count
-------------+-------
eblevins | 23595
DaClyde | 11031
zombiechick | 159
Drew | 104
(4 rows)
what I want to do is have one statement that returns something like this:
uid | count1 | count2
eblevins 1179 23595
DaClyde 398 11031
Drew 30 104
zombiechick 3 159
So everything is ordered like statement 1 but includes the count(uid) from the points DB like statement 2 returns
Any ideas on an effecient way of doing this?
From | Date | Subject | |
---|---|---|---|
Next Message | Oliver Elphick | 2002-10-16 20:38:59 | Re: Help with SQL |
Previous Message | Vincent Stoessel | 2002-10-16 17:43:07 | Quick contraint question |