At the moment I have a query in MySQL that adds the consumption that a certain person did in a time range:
SELECT e.codigo, round(sum(c.valor),2) as cupo FROM tbl_consumo c
INNER JOIN tbl_empleado e
on c.tbl_empleado_id=e.id
WHERE fecha like '%2018-12%'
GROUP BY e.codigo;
Then the tables have the following data:
Table_persons:
- Pepe
- Maria
- Gonzalo
- Paulina
Consumption_table
- 2018/12/18 1 Pepe
- 2018/12/01 1 Gonzalo
- 2018/11/18 1 Gonzalo
- 2018/12/20 1 Maria
- 2018/11/05 1 Pepe
The result is as follows:
- Pepe 1
- Gonzalo 1
- Maria 1
But I want the result to show me zero to the user without consumption.
- Pepe 1
- Gonzalo 1
- Maria 1
- Paulina 0
There is some way to raise it