I am using create payment receipt i will pay some amount like below example
this already created receipt but again have pay due_amount
cust_id cust_name invoice_id paid_amount due amount makeapayment
1001 SAS 545 76 305 sasi
This is the result of my query.
I have to pay due amount 100 then create another row after paying in same "id" view new row old row not view only stay in database see result like this
cust_id cust_name invoice_id paid_amount due amount makeapayment
1001 SAS 545 76 205 sasi
present i am using query
SELECT pid, cust_id, cust_name, date, invoice_id, invoice_date, invoice_amount, paid_amount, paymentmade, makeapayment, due_amount, status FROM print_reciept
group by cust_id having due_amount!='0' ORDER BY pid DESC
I think you can try this
SELECT pid, cust_id, cust_name, date, invoice_id, invoice_date, invoice_amount, paid_amount, paymentmade, makeapayment, due_amount, status
FROM print_reciept AS pr
INNER JOIN (
SELECT MAX(pid) AS last_pid, cust_id
FROM print_reciept
GROUP BY cust_id
) AS tmp ON (tmp.cust_id = pr.cust_id AND tmp.last_pid > pr.pid)
GROUP BY cust_id
ORDER BY pid DESC