Click here to Skip to main content
11,438,069 members (47,929 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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 4-Dec-12 3:06am
anshu77473

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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;
  Permalink  

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



Advertise | Privacy | Mobile
Web01 | 2.8.150506.1 | Last Updated 4 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100