вот таблица:
create table video_call (
timestamp timestamp,
callerid int,
receiverid int,
call_length int);
insert into video_call values
('2018-12-12 01:01:01', 1, 2, 3),
('2019-01-01 01:01:01', 1, 3, 5),
('2019-01-01 01:01:01', 2, 4, 3),
('2019-01-01 01:01:01', 5, 6, 3),
('2019-01-02 01:01:01', 3, 4, 3),
('2019-01-03 01:01:01', 3, 5, 3),
('2019-01-04 01:01:01', 3, 7, 3);
Теперь я хотел бы получить новых пользователей в день 2019-01-01
. Вот мой ответ:
select user from
(select distinct callerid as user from video_call where to_char(timestamp, 'YYYY-MM-DD') = '2019-01-01'
union
select distinct receiverid as user from video_call where to_char(timestamp, 'YYYY-MM-DD') = '2019-01-01') as t
where user not in
(select distinct callerid as user from video_call where to_char(timestamp, 'YYYY-MM-DD') < '2019-01-01'
union
select distinct receiverid as user from video_call where to_char(timestamp, 'YYYY-MM-DD') < '2019-01-01');
тогда получите эту ошибку:
ERROR: operator does not exist: name = integer
LINE 5: where user not in
^
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
SQL state: 42883
Character: 250
Есть идеи об этом? Я уже проверил, что все подзапросы работают. Спасибо