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')))


I need COALESCE(alreadyReleased, 0)
Was this page helpful?