Received: from tmg.themecca.net (alewis@themecca.net [207.252.220.51] (may be forged)) by hub.org (8.9.3/8.9.3) with ESMTP id MAA21995 for ; Thu, 27 May 1999 12:24:02 -0400 (EDT) (envelope-from alewis@themecca.net) Received: from localhost (alewis@localhost) by tmg.themecca.net (8.9.1/8.9.3) with ESMTP id LAA23215 for ; Thu, 27 May 1999 11:23:59 -0500 Date: Thu, 27 May 1999 11:23:59 -0500 (CDT) From: Andy Lewis To: pgsql-sql@postgresql.org Subject: 2 Table Select Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII I am trying to get the _total_ number of jobs that each company has in the db. In other words I want to get each distinct company that has jobs in the jobs table and the _total_ number of jobs that it has in the jobs table. What would be the best query that I could use? I'm using 6.4.2. Table = jobs +-------------+---------------+-------+ | Field | Type | Length| +-------------+---------------+-------+ | job_id | int4 not null | 4 | | company_id | int4 | 4 | | title | varchar() | 50 | ... +-------------+---------------+-------+ Table = company +--------------+---------------+-------+ |Field |Type | Length| +--------------+---------------+-------+ | company_id | int4 not null | 4 | | company_name | varchar() | 100 | | email | varchar() | 100 | ... +--------------+---------------+-------+ Thanks Andy