coalesce

I wonder how to make COALESCE(smth, 0) with drizzle? Postgresql
const sq = tx.select({
paymentId: settlementTransaction.paymentId,
alreadyReleased: sum(settlementTransaction.amount).as('alreadyReleased')
})
.from(settlementTransaction)
.groupBy(settlementTransaction.paymentId)
.as('sq');


let r = await tx
.select()
.from(payment)
.leftJoin(sq, eq(sq.paymentId, payment.id))
.where(and(eq(payment.fromCustomerId, s.fromCustomerId), eq(payment.type, 'PREPAID')))
const sq = tx.select({
paymentId: settlementTransaction.paymentId,
alreadyReleased: sum(settlementTransaction.amount).as('alreadyReleased')
})
.from(settlementTransaction)
.groupBy(settlementTransaction.paymentId)
.as('sq');


let r = await tx
.select()
.from(payment)
.leftJoin(sq, eq(sq.paymentId, payment.id))
.where(and(eq(payment.fromCustomerId, s.fromCustomerId), eq(payment.type, 'PREPAID')))
I need COALESCE(alreadyReleased, 0)
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server