Help on (sub)-select

Поиск
Список
Период
Сортировка
От Gary Stainburn
Тема Help on (sub)-select
Дата
Msg-id 200212201021.50475.gary.stainburn@ringways.co.uk
обсуждение исходный текст
Ответы Re: Help on (sub)-select  (Philip Warner <pjw@rhyme.com.au>)
Список pgsql-sql
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     



В списке pgsql-sql по дате отправления:

Предыдущее
От: Christoph Haller
Дата:
Сообщение: Re: UPDATE with a SELECT and subSELECT(About comparing dates and non dates data)
Следующее
От: Philip Warner
Дата:
Сообщение: Re: Help on (sub)-select