1
I have a SELECT
with SUM
and would like to understand how I do to return me the lowest sum of all value per supplier.
SELECT distinct fornecedor, cliente, SUM(valor*qtd) AS TOTAL FROM orcamentos
WHERE idOrcamento ='$orcamento' group by fornecedor;
The Table sums all values of each supplier.
I need the result to show me the lowest value found among suppliers.
Example this search above returned
|supplier | Customer | TOTAL|
|1________| 1_____ | 10.00|
|2________| 1 _____ | 11.00|
|3________| 1 _____ | 10.50|
How do I make SELECT return only the line with lower value?
with
min
..... that is to say,MIN(valor*qtd)
– novic
SELECT cliente, min(valor*qtd) from orcamentos WHERE idOrcamento =$orcamento group by cliente
is the smallest per customer so ???– novic
correct, based on the values of each supplier
– Junior