I want to select client transactions by means of generated by person.
It should show me all call back, appointment, sent email or any other status's count for particular agent (generated by id).
Schema:
CREATE TABLE IF NOT EXISTS `client_transaction` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`client_id` int(11) NOT NULL,
`generated_by_id` int(11) NOT NULL,
`schedule_for_id` int(11) NOT NULL,
`transaction_type` varchar(50) NOT NULL,
`target_date_time` datetime NOT NULL,
`date_added` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `client_id` (`client_id`)
)
Query:
SELECT generated_by_id as agent_id, count(*) as call_backs
FROM client_transaction
WHERE transaction_type='CALL_BACK'
GROUP BY generated_by_id
I have created query for one status. But, I need it for every status. And I also want to get agent name from other agent table. After getting all appropriate data, how can I left join with agent table?
Thanks.