dimanche 15 mars 2015

Month wise Opening Balance of stock


Vote count:

-1




Table is oinm and columns are below




/start/



SELECT
DISTINCT
DATEPART(MONTH, DocDate) AS 'Month' ,
DATENAME(MONTH, ( X.DocDate )) AS 'MonthName' ,
DATENAME(YEAR, ( X.DocDate )) AS 'Year' ,
X.ItemCode ,
X.Dscription ,
ISNULL(( SELECT SUM(A.InQty - A.OutQty)
FROM OINM A
WHERE A.ItemCode = X.ItemCode
AND A.DocDate < X.DocDate
GROUP BY A.ItemCode
), 0) AS 'Opening Balance'
FROM OINM X
WHERE X.ItemCode = 'A0001'
AND X.DocDate > DATEADD(yyyy, -1, '20150228')
AND X.DocDate < '20150228'
GROUP BY DocDate ,
ItemCode ,
Dscription
ORDER BY DATENAME(YEAR, ( X.DocDate ))


/end of query/


i want to pull opening balance for each month , but am not getting the result what i want,any help will be appreciated.



asked 1 min ago







Month wise Opening Balance of stock

Aucun commentaire:

Enregistrer un commentaire