How to count columns when parapameter?
I need to count all clients which when you subtract todays date/current(ex; 2013-10-28) to birth_date column(ex; 2001-15-13) returns "<= 6 months"
I have a this mysql query:
$query = 'SELECT b.record_number,
CONCAT(b.fname," ",b.lname) AS fullname,
province.area_name AS province,
district.area_name AS district,
llg.area_name AS llg,
office.area_name AS office,
c.clinic_name,
a.feeding_type,
COUNT(NOW, b.date_birth), - this is my code
b.date_birth,
FROM tbl_records AS a
JOIN tbl_client AS b ON a.client_id = b.ID
JOIN tbl_clinic AS c ON a.clinic_id = c.ID
JOIN tbl_area AS llg ON c.llg_id = llg.ID
JOIN tbl_area AS district ON llg.parent_ids = district.ID
JOIN tbl_area AS province ON district.parent_ids = province.ID
JOIN tbl_area AS office ON office.ID = a.office_id
WHERE a.date >= :start_date AND a.date <= :end_date
AND a.feeding_type <> "NULL" AND a.office_id = :office_id
GROUP BY a.client_id';