Friday, 23 August 2013

PostgreSQL - select results if related conditions where not existent

PostgreSQL - select results if related conditions where not existent

Is it possible in PostgreSQL to filter rows in way that it would show one
table rows that are related with other tables empty rows in some time
interval.
In other words imagine this example:
There are two tables partners and calls.
create table partners(
id int,
name varchar(100),
call_id references calls (id),
PRIMARY KEY (id)
);
create table calls(
id int,
name varchar(100),
date datetime,
PRIMARY KEY (id),
);
So imagine this now. There are some rows created in partners table. Some
calls made and rows appeared in calls (where date is registered when calls
were made). But I need to filter the opposite. How to see partners that
has no calls let say in dates between 2013-05-01 and 2013-06-01?
What I don't get it is how to filter partners with non existent records in
any period (if period wouldn't be required, then it would be easy. I could
just filter partners which have no calls)? Do I need to use external time
or something?

No comments:

Post a Comment