Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- supplier_info
- +----+------+--------+
- | id | s_id | s_name |
- +----+------+--------+
- | 1 | 101 | John |
- | 2 | 102 | Robin |
- | 3 | 103 | Harry |
- +----+------+--------+
- Due_info
- +----+------+------------+----------+-----+-----+----+-----+------+
- | id | s_id | due_dt | due_amnt | | | | | |
- +----+------+------------+----------+-----+-----+----+-----+------+
- | 1 | 102 | 2014-10-15 | 10000 | | | | | |
- | 2 | 101 | 2014-08-10 | 6350 | | | | | |
- | 3 | 103 | 2014-07-01 | 8650 | | | | | |
- | 4 | 101 | 2013-10-12 | 4650 | | | | | |
- | 5 | 102 | 2014-01-10 | 9860 | | | | | |
- | 6 | 103 | 2014-02-20 | 11350 | | | | | |
- +----+------+------------+----------+-----+-----+----+-----+------+
- Payment_info
- +----+------+------------+-----------+---------+
- | id | s_id | paid_dt | paid_amnt | paid_by |
- +----+------+------------+-----------+---------+
- | 1 | 103 | 2014-10-18 | 3000 | cash |
- | 2 | 101 | 2014-09-11 | 2000 | cheque |
- | 3 | 102 | 2014-10-18 | 6000 | card |
- | 4 | 103 | 2014-03-05 | 1890 | cash |
- | 5 | 102 | 2014-09-01 | 3500 | cash |
- | 6 | 101 | 2014-07-07 | 4200 | cheque |
- | 7 | 103 | 2014-03-05 | 1890 | cash |
- | 8 | 102 | 2014-09-01 | 3500 | cash |
- | 9 | 101 | 2014-07-07 | 4200 | cheque |
- +----+------+------------+-----------+---------+
- I want to get the result like this:
- +------+--------+-----------+------------+------------+
- | s_id | s_name | total_due | total_paid | remain_due |
- +------+--------+-----------+------------+------------+
- | 101 | John | 11000 | 10400 | 600 |
- | 102 | Robin | 19860 | 13000 | 10360 |
- | 103 | Harry | 20000 | 6780 | 13220 |
- +------+--------+-----------+------------+------------+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement