Using Ecto Fragments, how can i perform subtraction on two Database fields

How can I perform the follow function using ecto fragments

Transaction
|> Enum.map(& &1.amount - &1.amountPaid)

You shouldn’t need fragments. You could do this:

from r in Row, select: %{amount_unpaid: r.amount - r.amount_paid}
1 Like