I have two different queries:
Is:
select SUM(calidadProducto) from calidad cal where cal.codigo = 50;
which will return the value 11.
And this:
select COUNT(calidadProducto) from calidad cal where cal.codigo = 50;
which will return the value 4.
What I need is to divide (mathematically speaking) the queries. And so get the result: 2.75 or 3 if it returns as an integer. Because what I have is the total sum and the quantities, I need to do that division to obtain the average.
Any column can be the result of two columns. Since what you have there has the same condition as
where
, then it can be reduced to a column:Be careful, this does not mean that the query is optimal or fast, but it solves your problem
I know it's late to answer your question but it may help someone else, you can just put:
and it will give you the average of the column