I want to show information from each provider, make a sum of how much income they had on a certain date.
Mi tabla entrada
-----------------------
cajas peso idproveedor
-----------------------
100 1000 1
100 2000 1
Tabla proveedor
-----------------------
id nombre
-----------------------
1 Manuel Morales
I was doing it like this:
SELECT
COALESCE(SUM(cajas),0) as total_cajas,
COALESCE(SUM(peso),0) as total_peso
FROM entrada INNER JOIN entrada.idproveedor = proveedor.id
but it gives me an error. How could I do to get the following result?
---------------------------------------------------------
idproveedor nombre_proveedor total_cajas total_peso
---------------------------------------------------------
1 Manuel Morales 200 3000
and so on with each provider
You can do it like this:
Hello, I think that the recommended thing in this case is to use Group By (MySQL).
I leave you the SQLFiddle link so you can play with the query http://sqlfiddle.com/#!9/f41acc/3
Greetings.