Received: from vagabond.bde.espci.fr (ppp0.globenet.org [62.160.23.193]) by hub.org (8.9.2/8.9.1) with ESMTP id PAA26759 for ; Thu, 4 Feb 1999 15:43:48 -0500 (EST) (envelope-from pat@patoche.org) From: pat@patoche.org Received: (from pat@localhost) by vagabond.bde.espci.fr (8.8.8/8.8.8/Debian/GNU) id VAA00553 for pgsql-sql@postgresql.org; Thu, 4 Feb 1999 21:39:29 +0100 Message-Id: <199902042039.VAA00553@vagabond.bde.espci.fr> X-Mailer: XFMail 1.3 [p0] on Linux X-Priority: 3 (Normal) Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit MIME-Version: 1.0 Date: Thu, 04 Feb 1999 21:39:28 +0100 (CET) To: pgsql-sql@postgresql.org Subject: problem with join & count Hi, I don't succeed to build an SQL to do the task i describe below. If someone can helps, thanks in advance. I have two tables number | name -------------- 1 | toto 2 | titi 3 | tutu (here the number is a primary key) and number | tag --------------- 1 | alpha 1 | beta 2 | gamma 3 | zeta 3 | epsilon the number in the left column is the same of the number in the first table, but can appear in that second table many times. i need an sql query that will return: name | how_often ------------------- toto | 2 titi | 1 tutu | 2 that is, the result table should contain all names present in the first table and then the number of times the number associated with the name appears in the second table. Thanks a lot for your help. Patrick /\//\/\/\\/\/\//\/\\/\/\\/\\/\//\/\\/\//\/\\/\//\/\\/\//\/\\ Patrick M. pat@patoche.org http://www.patoche.org/