Advertisement
arahimabhi

Untitled

Oct 19th, 2014
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. supplier_info
  2. +----+------+--------+
  3. | id | s_id | s_name |
  4. +----+------+--------+
  5. | 1 | 101 | John |
  6. | 2 | 102 | Robin |
  7. | 3 | 103 | Harry |
  8. +----+------+--------+
  9.  
  10. Due_info
  11. +----+------+------------+----------+-----+-----+----+-----+------+
  12. | id | s_id | due_dt | due_amnt | | | | | |
  13. +----+------+------------+----------+-----+-----+----+-----+------+
  14. | 1 | 102 | 2014-10-15 | 10000 | | | | | |
  15. | 2 | 101 | 2014-08-10 | 6350 | | | | | |
  16. | 3 | 103 | 2014-07-01 | 8650 | | | | | |
  17. | 4 | 101 | 2013-10-12 | 4650 | | | | | |
  18. | 5 | 102 | 2014-01-10 | 9860 | | | | | |
  19. | 6 | 103 | 2014-02-20 | 11350 | | | | | |
  20. +----+------+------------+----------+-----+-----+----+-----+------+
  21.  
  22. Payment_info
  23. +----+------+------------+-----------+---------+
  24. | id | s_id | paid_dt | paid_amnt | paid_by |
  25. +----+------+------------+-----------+---------+
  26. | 1 | 103 | 2014-10-18 | 3000 | cash |
  27. | 2 | 101 | 2014-09-11 | 2000 | cheque |
  28. | 3 | 102 | 2014-10-18 | 6000 | card |
  29. | 4 | 103 | 2014-03-05 | 1890 | cash |
  30. | 5 | 102 | 2014-09-01 | 3500 | cash |
  31. | 6 | 101 | 2014-07-07 | 4200 | cheque |
  32. | 7 | 103 | 2014-03-05 | 1890 | cash |
  33. | 8 | 102 | 2014-09-01 | 3500 | cash |
  34. | 9 | 101 | 2014-07-07 | 4200 | cheque |
  35. +----+------+------------+-----------+---------+
  36.  
  37. I want to get the result like this:
  38. +------+--------+-----------+------------+------------+
  39. | s_id | s_name | total_due | total_paid | remain_due |
  40. +------+--------+-----------+------------+------------+
  41. | 101 | John | 11000 | 10400 | 600 |
  42. | 102 | Robin | 19860 | 13000 | 10360 |
  43. | 103 | Harry | 20000 | 6780 | 13220 |
  44. +------+--------+-----------+------------+------------+
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement