Hey guys, another question. Can we write queries l...
# orm-help
e
Hey guys, another question. Can we write queries like this with Prisma?
Copy code
SELECT 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
Copy code
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.
r
@Eric Martinez ๐Ÿ‘‹ Currently this insโ€™t possible, but you could consider this as an extension of this feature request. Also you could create a new one here as well. As for this, currently the most efficient would be the raw query.
๐Ÿ‘ 1
e
Thank you @Ryan again haha. I'll add my thoughts in that issue to avoid adding more noise.
โœ… 1