pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] 2 Table Select
Date: Sun, 30 May 1999 14:24:54 +0300
Message-ID: <l03130301b376cff230ad@[147.233.159.109]> (raw)
In-Reply-To: <199905271934.UAA07954@linda.lfix.co.uk>
References: <alewis@themecca.net>
	<Pine.LNX.4.05.9905271105190.22984-100000@tmg.themecca.net>

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





view thread (4+ messages)

Message-ID: <l03130301b376cff230ad@[147.233.159.109]>
Permalink:  ../l03130301b376cff230ad@%5B147.233.159.109%5D/
Also on:    postgresql.org/message-id/l03130301b376cff230ad@[147.233.159.109]

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: herouth@oumail.openu.ac.il
  Subject: Re: [SQL] 2 Table Select
  In-Reply-To: <l03130301b376cff230ad@[147.233.159.109]>
  References: <alewis@themecca.net> <Pine.LNX.4.05.9905271105190.22984-100000@tmg.themecca.net> <l03130301b376cff230ad@[147.233.159.109]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox