Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
dear sir,
i have 4 coloums like :(serial No. , received, send, balance)

serial No. received_item send_item balance
1 5
2 5 0 10
3 20 0 30
4 10 5 35
5 0 3 32
6 10 2 40

here received item added in balance and send items minus from balance and balance is added next received item and send items subtracted from balance and so on....

now if i want update value of received items of serial no. 3
like 25 in place of 20 then total increase by 5 at all place of balance coloumn after serial no. 3


AFTER updatation:-

serial No. received_item send_item balance
1 5
2 5 0 10
>Update here 3 25 0 35
4 10 5 40
5 0 3 37
6 10 2 45

what should i do for this..


reply plzzzz
Posted

1 solution

You don't need to keep balance values in the table. Balance can be calculated whenever you fetch the data. Use the following query.

SELECT
sernum,
received,
send,
(select sum(received)-sum(send) from stock s2 where s2.sernum<=s1.sernum) AS Balance
FROM Stock AS s1;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900