3
Answers

How to assign a variable in select statement

Abdu Rafeeq

Abdu Rafeeq

13y
1.6k
1

  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)