I have Some filedvalues say OpeningWt,SalesDetails and Balance fro differwnt table
select
opWt.OpeningWt as OpeningWt,
sales.SalesDetails as SalesDetails ,
opWt.OpeningWt-sale.SalesDetails as Balance
from sales inner join opWt on opWt.id=sales .id
This is sample query for selecting values.
I got balance , this balance assign to openingwt for next row
How assign in select statement
this type of answer i required
OpenigWt SalesDetails Balance
0 5 5
5 8 -3
-3 9 -12
I think any loop can use? i dont know how to use.. pls help me
Loading
Suthish NairPosted May 17, 2011, 5:43 AM
If am not wrong you want the closing balance to be the opening balance of next row?
refer thread: Save previous row value to next row..
Posted May 17, 2011, 4:47 AM
You can try this way also,
select
sales.OpeningWt as OpeningWt,
sales.SalesDetails as SalesDetails,
sales.OpeningWt-sale.SalesDetails as Balance
from
sales
Suthish NairPosted May 17, 2011, 4:29 AM
with cte as (