M
Marc Robillard
hi all,
Quick question for you expert !
I got 3 table
Bill
BillDet
BillPayment
I need on 1 query to obtain : Bill_id, Sum(Billdet_ItemTotal), and
Sum(BP_Amount)
Tables goes like this
Bill
Bill_id PK
....
BillDet
BillDet PK
Bill_id FK
Billdet_ItemTotal
....
BillPayment
Bp_id
Bill_id
BP_Amount
....
the Query I need is to return all Bill that have a payment Greater or equals
to the bill Total.
here is what I got : but Access is king of messing the caculation, I don't
know Why! It will return the correct BillTotal, but only the last
PaymentTotal is good.
SELECT DISTINCT Bill.Bill_id, Sum(BillDetails.BillDet_TotalItem) AS
SumOfBillDet_TotalItem, Sum(Bill_Payment.BP_Amount) AS SumOfBP_Amount,
Bill_1.Bill_id
FROM (Bill AS Bill_1 INNER JOIN (Bill INNER JOIN BillDetails ON Bill.Bill_id
= BillDetails.Bill_id) ON Bill_1.Bill_id = Bill.Bill_id) LEFT JOIN
Bill_Payment ON Bill_1.Bill_id = Bill_Payment.Bill_id
GROUP BY Bill.Bill_id, Bill_1.Bill_id
Regards to all !
Thanks in advence.
Marc. R.
Quick question for you expert !
I got 3 table
Bill
BillDet
BillPayment
I need on 1 query to obtain : Bill_id, Sum(Billdet_ItemTotal), and
Sum(BP_Amount)
Tables goes like this
Bill
Bill_id PK
....
BillDet
BillDet PK
Bill_id FK
Billdet_ItemTotal
....
BillPayment
Bp_id
Bill_id
BP_Amount
....
the Query I need is to return all Bill that have a payment Greater or equals
to the bill Total.
here is what I got : but Access is king of messing the caculation, I don't
know Why! It will return the correct BillTotal, but only the last
PaymentTotal is good.
SELECT DISTINCT Bill.Bill_id, Sum(BillDetails.BillDet_TotalItem) AS
SumOfBillDet_TotalItem, Sum(Bill_Payment.BP_Amount) AS SumOfBP_Amount,
Bill_1.Bill_id
FROM (Bill AS Bill_1 INNER JOIN (Bill INNER JOIN BillDetails ON Bill.Bill_id
= BillDetails.Bill_id) ON Bill_1.Bill_id = Bill.Bill_id) LEFT JOIN
Bill_Payment ON Bill_1.Bill_id = Bill_Payment.Bill_id
GROUP BY Bill.Bill_id, Bill_1.Bill_id
Regards to all !
Thanks in advence.
Marc. R.