SQL: HAVING clause
Posted
by Craig Johnston
on Stack Overflow
See other posts from Stack Overflow
or by Craig Johnston
Published on 2010-04-30T14:45:04Z
Indexed on
2010/04/30
14:47 UTC
Read the original article
Hit count: 198
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?
© Stack Overflow or respective owner