Forum Moderators: open
here is the string i am trying to work with:
$sql = 'SELECT nhm_associate, COUNT(nhm_associate) AS weekscount, (SELECT COUNT(*) FROM registration_table WHERE DATE_SUB(CURDATE(),INTERVAL 2 DAY) = entry_time GROUP BY nhm_associate) AS yesterday, (SELECT COUNT(*) FROM registration_table WHERE DATE_SUB(CURDATE(),INTERVAL 6 DAY) <= entry_time) AS totalcount FROM registration_table WHERE DATE_SUB(CURDATE(),INTERVAL 6 DAY) <= entry_time GROUP BY nhm_associate';
the first part counts any records entered into table over the previous 6 days, and groups them by nhm_asociate.
the second part, is my problem. i want it to count back only 2 days, and group the records entered only on that day. not for the previous 2 days combine, just "yesterday".
the third part works fine, as i just a total of all records for all agents to get a grand total....
can anyone shed some light on how i can use a pivot table to make this work?