Example query:
SELECT *, 
       lag(sum(sales), 1) OVER(PARTITION BY department
       ORDER BY date ASC) AS end_date_sales
FROM revenue
GROUP BY department, date;
I want to show only the rows where end_date is not NULL.
Is there a clause used specifically for these cases? WHERE or HAVING does not allow aggregate or window function cases.
                        
One method uses a subquery:
That said, I don't think the query is correct as you have written it. I would assume that you want something like this:
Where
?is a column such as the customer id.