0

I have two unsigned int fields in my DB. I want to run a query that returns a division between those fields using Prisma ORM.

SELECT CAST (COALESCE(total_1/count_1, 0) + COALESCE(total_2/count_2, 0) AS SIGNED) AS
avg_amount FROM table_name WHERE unrelated_field = x

How can I do that? I also thought of using a MySQL view for that but doesn't look like Prisma supports that either.

amiregelz
  • 1,833
  • 7
  • 25
  • 46
  • You would need to use Raw Queries to achieve this: https://www.prisma.io/docs/concepts/components/prisma-client/raw-database-access – Nurul Sundarani Dec 13 '22 at 17:38

0 Answers0