1. am present for 10 days my salary is rupees 10000
2. per day my salary is (10000/31=322).
3. so 10days my salary is 322*10=3220
4.but my need is 5000.
5.am going to get 5000rupees as advance.(5000-3220=1780)
6.i have to pay 1780 for my company
7.if i releve means i have to pay to the company rupees 1780.
8. but i continue my work in my company .i never to show the worked days that is (point no 1)
9.again i worked for the company 6 days (6*322=1932) . i have to give the 1780 amount to the company (1932-1780=152) 152 rupes my company have to give.after 6 days i need to show the balance in my account as 152
10.again am working for the company 15 days so my 15 days salary is (15*322=4830). now i have the total salary as 4830+152=4982.
11. so 15 days salary plus my 6 th day remaining salary i need this output
but in my query it shows the totoal present days. in case i got the advance i need to do like this