if(pb.iLab = 1,
0,
ifnull(
(SELECT sum(p_bi.dTotalAmount) amount
FROM patientbillitem p_bi, patientbillpayment p_b
WHERE p_bi.vRefReceipt = p_b.vReceiptNo
AND p_b.iBillNo = pb.iBillNo
AND p_bi.vItemCode = pbi.vItemCode),
0))
- (ifnull(
(SELECT sum(p_bi.discountAmount) amount
FROM patientbillitem p_bi, patientbillpayment p_b
WHERE p_bi.vRefReceipt = p_b.vReceiptNo
AND p_b.iBillNo = pb.iBillNo
AND p_bi.vItemCode = pbi.vItemCode),
0))
dRefund,
任何人指导我在select语句中编写此dRefund的任何其他方法谢谢。