Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select extract(year from fecha_creacion) as anio, extract(month from fecha_creacion) as mes,
- sum(case when tipo = 'entrada' then 1 else 0 end )
- from documento
- group by extract(year from fecha_creacion), extract(month from fecha_creacion)
- order by anio, mes;
- $data = DB::table('documento')
- ->selectRaw('year from fecha_creacion AS anio, month from fecha_creacion AS mes')
- ->sum(case when tipo = 'entrada' then 1 else 0 end )
- ->orderBy(anio, mes, DESC)
- ->get();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement