Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Select rows with no intersection on join table and check by date
--PostgreSQL 9.6 --'\\' is a delimiter create table source (created_at DATE, num INT, name VARCHAR(255)); create table filter (created_at DATE, num INT); insert into source (created_at, num, name) values ('2018-01-01', 1, '11'), ('2018-01-02', 2, '22'), ('2018-01-03', 3, '33'), ('2018-01-03', 9, '99'), ('2018-01-04', 4, '44'), ('2018-01-05', 5, '55'); insert into filter (created_at, num) values ('2018-01-01', 1), ('2018-01-02', 2), ('2018-01-03', 3), ('2018-01-04', 1), ('2018-01-05', 4), ('2018-01-05', 7); select * from source; select * from filter; select * from source left join filter on filter.num = source.num where filter.num IS NULL and source.created_at >= '2018-01-01' and source.created_at <= '2018-01-05' order by source.created_at asc ;
run
|
edit
|
history
|
help
0
postgresql timestamp
postgresql
post
Return IDs where there are exactly 3 occurrences
POSTGRESQL_CLOSEST_VALUE
as
project 1
Projeto
SQL hierarchical query. branch of responses.
renaming JSON field