Forum Moderators: open

Message Too Old, No Replies

Pivot Table?

         

tonynoriega

8:49 pm on Aug 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



so i have only new been introduced to the "Pivot Table" coming across a problem i have been having trying to group two sets of queries in one query string...

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?