Hi
My query returns all the records of "active" London customers who have ordered within the past year. I also need to know how many customers, but where do I put the COUNT function?
SELECT *, MAX(customers_orders.date) AS maxdate,
customers.id AS refid,
FROM customers
LEFT JOIN customers_orders ON customers.id = customers_orders.custid
WHERE archived = 'no' AND city = 'London'
GROUP BY customers.id
HAVING maxdate >= DATE_SUB(NOW(),INTERVAL 1 YEAR)
Thanks in advance
slowfish
My query returns all the records of "active" London customers who have ordered within the past year. I also need to know how many customers, but where do I put the COUNT function?
SELECT *, MAX(customers_orders.date) AS maxdate,
customers.id AS refid,
FROM customers
LEFT JOIN customers_orders ON customers.id = customers_orders.custid
WHERE archived = 'no' AND city = 'London'
GROUP BY customers.id
HAVING maxdate >= DATE_SUB(NOW(),INTERVAL 1 YEAR)
Thanks in advance
slowfish