I'm doing college work on Database, and one of the Query
I should do is this:
- Show all lenders who have had a larger total purchase that R $ 5000.00;
I tried:
SELECT NomeCredor, SUM(Compras.Valor)
FROM Credores, Compras
WHERE (idCredores = Compras.Credores_idCredores)
AND (SUM(Compras.Valor)) > 5000
GROUP BY NomeCredor
ORDER BY NomeCredor;
The problem is that SUM(Compras.Valor)
can not be passed as a condition of WHERE
. Does anyone know an alternative?