Hello Everyone,
I have a Postgres database from which I am trying to extract maintenance information. In a nutshell, I am trying to use a subquery to find only the data that does NOT have a corresponding timestamp in the last 90 days.
I have a table that contains a phone number, a table that contains an address, and a table that contains interaction events, with EPOCH timestamps. I would like to find all of the phone numbers which have NOT had an interaction in the last 90 days.
I tried the below, but it did not work. Not sure what the issue is, but this is my first time trying to find something that is "NOT" in a respective time frame.
Thank you.
I have a Postgres database from which I am trying to extract maintenance information. In a nutshell, I am trying to use a subquery to find only the data that does NOT have a corresponding timestamp in the last 90 days.
I have a table that contains a phone number, a table that contains an address, and a table that contains interaction events, with EPOCH timestamps. I would like to find all of the phone numbers which have NOT had an interaction in the last 90 days.
I tried the below, but it did not work. Not sure what the issue is, but this is my first time trying to find something that is "NOT" in a respective time frame.
Thank you.
SQL:
SELECT CASE LEFT(l.value, 1)
WHEN '^' THEN SUBSTR(l.value, STRPOS(l.value,'+'), (LENGTH(l.value)-STRPOS(l.value,'+')+1))
ELSE l.value
END as value,
g.name,
i.sourcenumber
FROM central.phone l INNER JOIN central.address g ON l.locationid=g.id
WHERE g.name LIKE '%' AND
l.value IN (SELECT i.phonenumber
FROM central.interaction i
WHERE i.analyticstime NOT BETWEEN (i.analyticstime >= extract ('epoch' from timestamp '2018-12-12') * 1000 AND
i.analyticstime < extract ('epoch' from timestamp '2019-02-12') * 1000)
)
;