Abdu Rafeeq

Abdu Rafeeq

  • NA
  • 113
  • 265.4k

How to assign a variable in select statement

May 17 2011 3:55 AM

  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


Answers (3)