Which is the easiest way to make a query with multiple subtotals?
I have a table with the following characteristics: Curso: itemDocente varchar(10) codigoCurso varchar(20) pagoDocente float tipoCurso varchar(1) mesCurso varchar(10) A teacher has many courses. A course can be of 3 types: C, F or M. I made a query that returns all the courses of a teacher grouping them to get the totals to pay, but wanted to know if you can get the sum of each type of course per teacher at a time. SELECT itemDocente, CourseCode, round (payDocente, 2) as C FROM reporte_pagos where mesCourse like '$mes' GROUP BY itemDocente, codeCourse UNION SELECT itemDocente, null, round (sum (paymentDocente), 2) FROM reporte_pagos where mesCourse like '$mes' GROUP BY itemDocente Order by itemDocente, codeDescription desc