I’m noticing different values for these two different queries:
SELECT SUM (CASE WHEN date1 - date2 <= INTERVAL '1 year' THEN 1 ELSE 0 END)
SELECT SUM (CASE WHEN date1 <= date2 + INTERVAL '1 year' THEN 1 ELSE 0 END)
with the latter being less restrictive (larger sum).
Both date1
and date2
are Timestamps.
New contributor
Cody Cao is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.