From: Antti Linno <alligator@all.ee>
To: pgsql-sql@postgresql.org
Subject: Ancient postgres+EXCEPT
Date: Fri, 7 Jul 2000 10:10:50 +0300 (EEST)
Message-ID: <Pine.LNX.4.04.10007071002130.18559-100000@all.ee> (raw)
Lo. I have in my local machine quite new POstgresql
[PostgreSQL 6.5.3 on i586-pc-linux-gnu, compiled by gcc egcs-2.91.66]
but the machine, I am writing scripts for has some ancient postgres(btw,
how to see the version on psql, if its not shown at the start? ).
I made a query
SELECT ajaperiood.isik_id,struktuuriyksus,ametikood,tase,eesnimi_perenimi
FROM ajaperiood,ametikoht,isik,tootaja
WHERE perioodi_tyyp='tooleping'
AND
(
algus<=timestamp(date_trunc('month', timestamp 'today')-interval '1 day')
OR
algus is NULL
)
AND
(
lopp>=timestamp(date_trunc('month', timestamp 'today')-interval '1 day')
OR
lopp is NULL
)
AND
tootaja.isik_id=ajaperiood.isik_id
AND
ametikoht.id=tootaja.ametikoht_id
AND
ametikoht.ametikood='10'
EXCEPT
SELECT ajaperiood.isik_id,struktuuriyksus,ametikood,tase,eesnimi_perenimi;
and now I have to put it in such state, that doesn't have except, but does
the same thing. I guess something twice as big but with ANDs,ORs, or
smthng like this :(. But I don't have a clue.
As a comments, I can offer you this: I have four tables-
job,workers,persons and timeintervals. Job is connected through workers
with persons(that is the table that binds persons and jobs), and every
person can have multiple time intervals such as 'vacation','contract',
'stopped contract','unpaid vacation' ...
What I need is to get the list of workers, that have contract, but aren't
on vacation etc. It would be nice to get them with one query, but if its
impossible, than I have to code it the hard way *yawn*.
Antti
P.S. Sorry for not translating the field and table names, but I have a
mighty Sandman around me.
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: alligator@all.ee
Subject: Re: Ancient postgres+EXCEPT
In-Reply-To: <Pine.LNX.4.04.10007071002130.18559-100000@all.ee>
References: <Pine.LNX.4.04.10007071002130.18559-100000@all.ee>
* 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