Click here to Skip to main content
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 2:06am
anshu77456

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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 453
1 CPallini 333
2 George Jonsson 270
3 OriginalGriff 159
4 Prasad Khandekar 135
0 OriginalGriff 4,613
1 CPallini 3,340
2 Sergey Alexandrovich Kryukov 2,879
3 George Jonsson 2,264
4 Gihan Liyanage 2,020


Advertise | Privacy | Mobile
Web04 | 2.8.140905.1 | Last Updated 4 Dec 2012
Copyright © CodeProject, 1999-2014
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