Received: from mail1.stofanet.dk (IDENT:qmailr@mail1.stofanet.dk [212.10.10.6]) by hub.org (8.10.1/8.10.1) with SMTP id e7GDVFn66883 for ; Wed, 16 Aug 2000 09:31:15 -0400 (EDT) Received: (qmail 29484 invoked from network); 16 Aug 2000 13:31:11 -0000 Received: from pc77060.stofanet.dk (HELO fangorn.inspocknito) (mail@212.10.17.60) by mail1.stofanet.dk with SMTP; 16 Aug 2000 13:31:11 -0000 Received: from martin by fangorn.inspocknito with local (Exim 3.12 #1 (Debian)) id 13P2bj-0000AM-00 for ; Wed, 16 Aug 2000 14:47:47 +0200 To: pgsql-sql@postgresql.org Subject: Many-to-one subquery From: Martin Christensen Date: 16 Aug 2000 14:47:46 +0200 Message-ID: <87wvhh5q4t.fsf@fangorn.inspocknito> Lines: 18 User-Agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200008/146 I have a problem that I have not been able to solve efficiently, and I'm confident that it can be done in a single query. I have a mailing list archive that I want to do some statistics on. It would tremendously ease my work if I could extract such statistics for each individual poster in one go. That would, of course, be quite easy, if I could do a SELECT DISTINCT poster FROM maillist as a subquery and use that as an argument. For instance, if I have a function postpct(date, date, varchar(30)) that calculates the percentage of posts that a certain poster ($3) is responsible in a certain time interval ($1 to $2), then how do I go about feeding that function all distinct poster entries? I've tried different things with joins, but the bit that actually worked was horribly inefficient. Martin -- GPG public key: http://home1.stofanet.dk/factotum/gpgkey.txt