From: Richard Rowell <rwrowell@bellsouth.net>
To: pgsql-sql@postgresql.org
Subject: Multiple counts
Date: Wed, 26 Dec 2001 23:36:05 -0600
Message-ID: <20011227053930.DMEM18093.imf07bis.bellsouth.net@there> (raw)
I have a one-to-many relationship with a table structure like so:
create table call(
uid serial,
store int,
...)
create table status(
call_uid int,
status_uid int,
...)
First off, please note that the "call" table will get large ( growing by up
to 6k records per week) and the status table will grow linearly with it (n*20
or so).
With that in mind, what I am trying for is an efficient query to get a tuple
set like so:
store number_of_calls number_of_status_where_statusuid_iszero
I can get 1&2:
select store, count(*) from call group by store;
or 1&3:
select c.store,count(s.status_uid)
from call c, status s
where s.call_uid=c.uid
and s.status_uid=0
group by c.store
But all my lame attempts at getting both in the same query fail.
TIA
_________________________
Richard Rowell
rwrowell@bellsouth.net
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: rwrowell@bellsouth.net
Subject: Re: Multiple counts
In-Reply-To: <20011227053930.DMEM18093.imf07bis.bellsouth.net@there>
* 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