X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id B95C4D1B523 for ; Sun, 21 Sep 2003 15:01:02 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 95031-02 for ; Sun, 21 Sep 2003 12:00:51 -0300 (ADT) Received: from news.hub.org (unknown [64.117.224.194]) by svr1.postgresql.org (Postfix) with ESMTP id AA1DBD1BA80 for ; Sun, 21 Sep 2003 12:00:51 -0300 (ADT) Received: from news.hub.org (host-64-117-224-194.altec1.com [64.117.224.194] (may be forged)) by news.hub.org (8.12.9/8.12.9) with ESMTP id h8LF0phK089262 for ; Sun, 21 Sep 2003 15:00:51 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id h8LEcoV8086577 for pgsql-sql@postgresql.org; Sun, 21 Sep 2003 14:38:50 GMT From: Bob Hutzel Subject: Cross joining table with itself User-Agent: Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) Message-Id: X-Newsgroups: comp.databases.postgresql.sql MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Lines: 12 Date: Sun, 21 Sep 2003 14:38:23 GMT Organization: Optimum Online To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/238 X-Sequence-Number: 15216 I've been stumped trying to solve this problem via SQL. I have a table ID, member1, member2, member3. In any row, any member field may have a value or be null. I want to tally up how many times each member appears in the table as a whole. For example, if two entries were ('a', '', 'c') and ('b', 'c', ''), I'd like my final result to be: a, 1 b, 1 c, 2 Is this feasible? Thank you for any help.