>
>openingamount + nvl(purchaseamount,0) - nvl(soldamount,0) as [ClosingAmount] ;
>
>
>Nomi, thanks for helping but I want to draw you attention to above line of codes
>
>the closing qty will multiply by purchase rate
>
>The last purchase rate of 1401 is 14.775
>so closing amount of 1401=?
>
>closing amount=closing qty*last purchase rate
>14.775*6=88.65
>
>so closing amount of 1401=88.65
>
>But your query displays 59.70
In your sample data the last purchase rate for 1401 is 6.13
If it's not broken, fix it until it is.
My Blog