SQL: HAVING clause
- by Craig Johnston
See the following SQL statement:
SELECT datediff("d", MAX(invoice.date), Now) As Date_Diff, MAX(invoice.date) AS max_invoice_date, customer.number AS customer_number
FROM invoice INNER JOIN customer ON invoice.customer_number = customer.number
GROUP BY customer.number
If the the following was added:
HAVING datediff("d", MAX(invoice.date), Now) > 365
would this simply exclude rows with Date_Diff <= 365?
What should be the effect of the HAVING clause here?