Reputation: 455
I want to get the list of offices name that was working for us before 2015-01-01 and after 2016-01-01 but not between 2015-01-01 and 2016-01-01.
If try to put NOT BETWEEN then it will basically give me the result excluding that two dates.can somebody solve this ?
select distinct office_name
from history
where date not between '01-jan-2015' and '01-jan-2016'
Upvotes: 0
Views: 56
Reputation: 1271003
I think you want aggregation:
select office_name
from history
group by office_name
having sum(case when date between date '2015-01-01' and '2016-01-01' then 1 else 0 end) = 0;;
Upvotes: 3