I'm doing a search in db that needs to return the sum of a field and the last corresponding value, and grouping them to an index
Query
$stmt = getConn()->query("SELECT senha,movi,SUM(entrada) as entrada,custo FROM estoquemovimento ORDER BY id DESC");
$items = $stmt->fetchAll(PDO::FETCH_GROUP | PDO::FETCH_ASSOC | PDO::FETCH_UNIQUE);
Answer
Array
(
[NbpsCQAMyc] => Array
(
[movi] => Adicionado
[entrada] => 2.000
[custo] => 3.00
)
)
This is all correct, in formatting the array, only the cost is searching for the first record, not the last record
I need the search to return the cost of the last record