First page Back Continue Last page Image
A WHERE and a HAVING in the same Query
SELECT
invoice_date,
COUNT(*) AS invoice_qty,
SUM(invoice_total) AS invoice_sum
FROM invoices
WHERE invoice_date BETWEEN '2018-05-01' AND '2018-05-31'
GROUP BY invoice_date
HAVING COUNT(*) > 1
AND SUM(invoice_total) > 100
ORDER BY invoice_date DESC
You can use a WHERE clause and a HAVING clause in the same Query
You may even be able to optimize your query by the way you use these clauses together