I have the following query
SELECT count(dp.id_dieta) *
(select d.dieta from dietas d where d.idDietas = dp.id_dieta) as t
FROM dietaspartes dp
WHERE dp.id_parte in
(SELECT p.idparte as part
FROM partes p
WHERE p.IDProyecto = 1111)
GROUP BY id_dieta
That returns two results: 50 and 30
I would like to modify this query to return the sum of these two values, but with the possibility that if they are 3 or X, return the sum of those X values.
If I enclose it with a Sum it tells me that I make an invalid use of group by
I'm a bit blocked with this, thanks for the help.