Created
February 28, 2020 03:38
-
-
Save JasonTrue/2cc06bf094692c13480f1056b82d0d32 to your computer and use it in GitHub Desktop.
most_recent_notifications_older_than some date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select v.name, max(n.inserted_at) | |
from variables v | |
left join notifications n on v.id = n.variable_id | |
where tenant_id = 2 | |
group by v.name | |
having max(n.inserted_at) < '2020-02-28 12:25:07.000000' | |
or max(n.inserted_at) is null --disjunction clause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment