your query execute only this is not correct see another example below
pid customer id invoice id name due amount make payment
1 1001 086 sasi 36 sasi 10
5 1003 084 ram 100 ram 50
7 1002 083 koushil 80 am 50
query is
SELECT * FROM print_reciept pr INNER JOIN ( SELECT invoice_id, MIN(pid) AS min_pid FROM print_reciept WHERE due_amount != 0 GROUP BY invoice_id ) t ON pr.invoice_id = t.invoice_id AND pr.pid = t.min_pid WHERE due_amount != 0;
see this again example
pid customer id invoice id name due amount make_pay paid_amount
1 1001 086 sasi 36 sasi 10
2 1001 086 sasi 26 ram 5
3 1001 086 sasi 21 ravi 10
4 1001 086 sasi 11 sasi 10
5 1003 084 ram 100 ram 50
6 1003 084 raghu 50 sasi 10
7 1002 083 koushil 80 am 50
8 1002 083 koushil 30 am 20
this is my result but i am already pay due 6 amount in same id use invoice id 086
i need result
pid customer id invoice id name due amount make payment
4 1001 086 sasi 11 sasi 10
6 1003 084 raghu 50 sasi 10
8 1002 083 koushil 30 am 20