From: Gary Stainburn <gary.stainburn@ringways.co.uk>
To: pgsql-sql@postgresql.org
Subject: Help on (sub)-select
Date: Fri, 20 Dec 2002 10:21:50 +0000
Message-ID: <200212201021.50475.gary.stainburn@ringways.co.uk> (raw)
Hi Folks,
I have two tables
roster holds the duties to be performed and the number of people required per
duty.
roster_staff holds the people allocated to perform that duty.
I'm trying to create a select that will tally the roster_staff and include it
with the roster details. I've managed to get it working for a specific day,
but I can't seem to manage to get it working generically.
here's the select I've got that works, along with the output:
nymr=# select r.*, s.tally from roster r,
nymr-# (select count(*) as tally from roster_staff where
nymr(# rsdate = '2002-01-01' and rsgid = 11 and rsgsid = 2) as s
nymr-# where rodate = '2002-01-01' and rogid = 11 and rogsid = 2;
rodate | rogid | rogsid | rorequired | rooptional | tally
------------+-------+--------+------------+------------+-------
2002-01-01 | 11 | 2 | 0 | 1 | 2
(1 row)
nymr=#
What I want to be able to do is select multiple rows and have the correct
tally appear for that row.
--
Gary Stainburn
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
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: gary.stainburn@ringways.co.uk
Subject: Re: Help on (sub)-select
In-Reply-To: <200212201021.50475.gary.stainburn@ringways.co.uk>
* 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