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
Which returns me 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, it returns the sum of those X values.
If I englobe with a Sum it tells me that I make an invalid use of group by
I'm a bit stuck on this, thanks for the help.
The problem that the invalid use system gives you
group by
is because the value ofgroup by
must be part of theselect
, in your case you must placeIn the end I managed to solve it and it stays like this, maybe it will come in handy for someone