Eric Martinez
06/05/2021, 3:18 PMSELECT p.codigo, f.sumaPctPagado, b.id, b2.comentario
FROM proyecto p
LEFT JOIN (
SELECT sum(porc_hes) as sumaPctPagado, id_pry
FROM facturacion
GROUP BY id_pry
) f
ON p.codigo = f.id_pry
LEFT JOIN (
SELECT max(id) as id, id_pry
FROM bitacora
GROUP BY id_pry
) b
ON p.codigo = b.id_pry
LEFT JOIN bitacora b2
ON b.id = b2.id
I tried this
await prisma.proyecto.aggregate({
_sum: {
include: {
facturacion: {
porc_hes: true
}
}
}
});
And it's not possible, it failed immediatly. Should I "modularize" (move them out of the main query) the nested queries? I see that as an alternative but I haven't tried it yet.Eric Martinez
06/07/2021, 1:28 PM