table name: sb
studid studname amount
----------------------------------
1 a 1000
2 b 2000
3 c 1000
4 d 3000
table name: bill
studid amt_paid amt_due
----------------------------------
1 300 700
1 300 400
2 500 1500
2 500 1000
bill.studid is a foreign key of sb.studid
the amount paid is deducted from amount .
I need an output of this format
studid studname amount amt_paid amt_due
----------------------------------------------------------------------
1 a 1000 600 400
2 b 2000 1000 1000
3 c 1000 0 1000
4 d 3000 0 3000
help me in constructing the query?


Reply With Quote