We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

group by, count and sum in a model

Hello I was reviewing the documentation


in a query I can get added value, sumed or averaged, or counted by a group, but the model must create an object for each sum or count. You can create an object that has a number average ,sums and count

I did not get that. Can u give us example where is the issue?

Can explain what's your problem ? Don't understand.

edited Sep '16

I want to do this query with options Phalcon

 SELECT  case c.caja_formap when 'B' then 'BILLETE' when 'C' then 'MONEDAS' else 'OTROS' END AS TIPO,
count(c.caja_cantidad) as cuantos,  
sum(c.caja_cantidad) as cantidad,   
round(sum(c.caja_total),2) as total,
upper(expresar_en_letras.numero_a_letras(c. caja_valor))as valorletras
where to_char(c.caja_fecha,'dd/mm/yyyy')=to_char(sysdate,'dd/mm/yyyy')
group by c.caja_formap,c.caja_valor
ORDER BY c.caja_formap,c.caja_valor asc

Just use query builder ?