Hey all. I have the following query, is it possib...
# orm-help
p
Hey all. I have the following query, is it possible to do with Prisma?
Copy code
select id, name, "categoryId", a."createdAt" from forum_post fp 
inner join (select "postId", max("createdAt") as "createdAt" from forum_post_reply group by "postId") a on a."postId" = fp.id 
order by a."createdAt" desc;
Thanks
n
Hey Paul 👋 You should be directly able to invoke this query by using Raw Query. As per your query, you should be able to select specific fields, use include to get relation fields and use groupBy and orderBy
p
Hi @Nurul. Yes I'm doing it right now with Raw Query. Unfortunately I was only able to go so far with Prisma natively as I wasn't able to order (the main query) by the contents of the joined subquery. Hence the question.