Received: from mx99.openu.ac.il (arbel.openu.ac.il [147.233.32.4]) by hub.org (8.9.3/8.9.3) with ESMTP id HAA40115 for ; Sun, 30 May 1999 07:24:22 -0400 (EDT) (envelope-from herouth@oumail.openu.ac.il) Received: from talmon.openu.ac.il (talmon.openu.ac.il [147.233.32.11]) by mx99.openu.ac.il (Postfix) with ESMTP for id 475EB4B5D8; Sun, 30 May 1999 14:24:16 +0300 (IDT) Received: from [147.233.159.109] (mac-herouth.pc.openu.ac.il) by talmon.openu.ac.il (Netscape Messaging Server 3.54) with ESMTP id AAA3E7C for ; Sun, 30 May 1999 14:26:43 +0300 X-Sender: herouth@shaked.cc.openu.ac.il Message-Id: In-Reply-To: <199905271934.UAA07954@linda.lfix.co.uk> References: Message from Andy Lewis of "Thu, 27 May 1999 11:23:59 CDT." Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Sun, 30 May 1999 14:24:54 +0300 To: pgsql-sql@postgreSQL.org From: Herouth Maoz Subject: Re: [SQL] 2 Table Select At 22:34 +0300 on 27/05/1999, Oliver Elphick wrote: > > select c.company_id, count(j.job_id) > from company as c, jobs as j > where c.company_id = j.company_id > group by c.company_id; If it's only the company_id that interests you, and not the company name or other details in the company table, you can give up the company table altogether. The company_id appears in the jobs table, and there is no point in selecting c.company_id when the condition was that c.company_id is equal to j.company_id. In other words, if all you need is company_id, you can use: select company_id, count(job_id) from jobs group by company_id; Herouth -- Herouth Maoz, Internet developer. Open University of Israel - Telem project http://telem.openu.ac.il/~herutma