When i run following query it shows only 1 row. Based on “created_date” condition, where as if i remove “created_date” condition and just keep “status_change_date” condition it shows 3 rows.
I want to see all items those were created or modified in specified time. I am unable to find whats wrong in the query
`SELECT DISTINCT products.id AS product, status.id AS stat, COUNT(*) AS total FROM items
INNER JOIN products ON (items.fk_product_id = products.id)
INNER JOIN status ON (items.fk_status = status.id)
WHERE DATE(items.status_change_date) BETWEEN '2011-04-13' AND '2011-05-13'
OR DATE(items.created_date) BETWEEN '2011-04-13' AND '2011-05-13'
AND status.id = 2
GROUP BY products.name, status.name order by products.name`
Your WHERE clause looks wrong, try: