Ver originalselect max(total), idfechafactura from(Select sum(totalproducto) as total, idfechafactura from tblfacturagroup by idfechafactura) as t1 group by idfechafactura