I have three tables which I want to query in MySQL as follows:
Table employee
id | name_employee
-------------------
1 | John
2 | David
3 | Sara
4 | Tina
Table Status
id | name_status
-----------
1 | no process
2 | processing
3 | processed
Table Ticket
id | id_employee | id_status
----------------------------------
1 | 1 | 2
2 | 2 | 2
3 | 2 | 3
4 | 3 | 3
5 | 1 | 1
I need to query the result as follows:
name_employee | count(ticket.id) where id_status = 1 | count(ticket.id) where id_status = 2 | count(ticket.id) where id_status = 3
-----------------------------------------------------------------------------------------------------------------------------------------
David | 0 | 1 | 1
John | 1 | 1 | 0
Sara | 0 | 0 | 1
Any help much appreciated! Thanks very much!