hi , sorry for english :
i have this fiddle (there is a joined table in fiddle ) :
https://www.db-fiddle.com/f/5KHAmkAXTg6rsk5oJDnFH2/0
and this is my function model
Code:
public function lista_calcolo_totali_accorpati_per_codice(){
$inventario_model = new InventarioModel();
$id_inventario_attivo = $inventario_model->get_inventario_attivo();
$this->select('conta.magazzino, conta.codice_materiale,conta.numero_conta , conta.unita_misura , sum(conta.quantita) as quantita_totale , sap.valore_totale_sap , sap.valore_singolo_sap ,sap.quantita_sap');
$this->from([], true);//altrimenti scrive due volte conta materiale
$this->from('conta_materiale conta');
$this->join('sap_dati_ricevuti sap' , 'conta.codice_materiale = sap.codice_materiale');
$this->where('conta.id_inventario',$id_inventario_attivo);
$this->groupBy(['conta.codice_materiale','conta.magazzino','conta.numero_conta','conta.unita_misura']);
$res=$this->findAll();
return $res;
}
it return an entity sesultset object . How can i get only row where the same codice_magazzino have numero_conta at max value ?