Group and add in mysql. to create a report

0

I have the following table and I want to Group and add as in the following example that I put to you.

I commented that this table I will have in a view since it is the result of several tables. =)

DESIRED RESULT ...


I do not know how to add and group at the same time.

I'll put this in a view.

SELECT cod_prod,tipo_mesualidad,precio_servicio, fecha_Recibo, nivel_al 
FROM detarecibos as D 
INNER JOIN recibo as R ON D.id_Reci=R.cod_Recibo 
INNER JOIN alumnos as A ON R.id_alumnPago=A.id_al 
WHERE fecha_Recibo='2018-01-21'

I really want to do it clean so as not to get confused and start a new query from the view.

    
asked by Carlos 23.01.2018 в 06:13
source

1 answer

2

I do not know if this is what you are looking for. With this query you get the result you indicate in your question:

SELECT
nivel_al, SUM(cant) AS cant, tipo_mensualidad, SUM(precio_servicio) AS precio_servicio
FROM detallerecibos
GROUP BY nivel_al,tipo_mensualidad
    
answered by 23.01.2018 / 11:11
source