Re: Help With complex join
От | Richard Huxton |
---|---|
Тема | Re: Help With complex join |
Дата | |
Msg-id | 42D77A80.6060101@archonet.com обсуждение исходный текст |
Ответ на | Help With complex join (spinto@virtualslo.com) |
Список | pgsql-sql |
spinto@virtualslo.com wrote: > Hi all, got a question as how to approach a somewhat complicated join > query. The deal is I have three tables called attorney, lawOffice, and > law_office_employment. The attorney and lawOffice tables hold attorney > and lawOffice information respectively (obviously). The > law_office_employment table is meant to show historical periods of time > for which the attorney's worked for the different lawOffices. But it doesn't. Looking below, it shows the date they started in each law office, not the period they worked there. In fact, you can't capture a period of unemployment/sabbatical using just this table. > Here is > the create table statement for law_office_employment: > > /*==============================================================*/ > /* Table: LAW_OFFICE_EMPLOYMENT */ > /*==============================================================*/ > create table LAW_OFFICE_EMPLOYMENT ( > ATTORNEYID IDENTIFIER not null, > LAWOFFICEID IDENTIFIER not null, > STARTDATE DATE not null, > constraint PK_LAW_OFFICE_EMPLOYMENT primary key (ATTORNEYID, > LAWOFFICEID, STARTDATE) > ); Make your life easier and have start and end-dates. Oh, you might want a "finished-here" flag too to indicate the end-date can be checked. -- Richard Huxton Archonet Ltd
В списке pgsql-sql по дате отправления: