Subquery SUM #2914
Unanswered
infinitetrinity
asked this question in
Q&A
Subquery SUM
#2914
Replies: 1 comment
-
Inside the subquery, the column is final oPaymentQuery = selectOnly(orderPaymentsTable)
..addColumns([coalesce<int>(orderPaymentsTable.amount, Constant(0)).sum()])
..where(orderPaymentsTable.orderId.equalsExp(ordersTable.id)); Then, the column you're interested in is final totalPayment = coalesce<int>(subqueryExpression(oPaymentQuery, Constant(0))).sum(); You should be able to add that column to the topmost query and use it to read the results. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I'm trying to build this query that retrieve the total payment amount of each event.
Schema is:
Events > Orders > Order Payments
So far I got this
However, this does not return the correct sum of the total payment, only the first payment amount.
Any idea how I can sum it all correctly?
Thank you
Beta Was this translation helpful? Give feedback.
All reactions