Pascal Sthamer
06/30/2022, 11:07 AMSELECT
SUM(payment.price) AS 'income',
YEAR(payment.createdAt) AS 'year',
MONTH(payment.createdAt) AS 'month'
FROM
(
SELECT price, createdAt
FROM pay_pal_payment
WHERE status = ${PayPalPaymentStatusEnum.COMPLETED}
UNION ALL SELECT price, createdAt
FROM paysafecard_payment
WHERE status = ${PaysafecardPaymentStatusEnum.SUCCESS}
UNION ALL SELECT price, createdAt
FROM stripe_payment
WHERE status = ${StripePaymentStatusEnum.COMPLETED}
ORDER BY createdAt
) payment
GROUP BY year, month
ORDER BY year ASC, month ASC
Prisma used to return number
for income
, instead of Decimal
. I read the changes in Prisma 4, about $queryRaw
type mapping, but in this case it seems odd to me, that it returns a Decimal
, because price
is of type Int @db.UnsignedMediumInt
.Alex Ruheni