Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2756

Inventory Report in Query.

$
0
0

Experts correct my code how to get an exact code.


Thanks.



Declare @FromDate Datetime
Declare @ToDate Datetime
Declare @Whse nvarchar(10)
select @FromDate = min(S0.Docdate) from dbo.OINM S0 where S0.Docdate >='[%0]'
select @ToDate = max(S1.Docdate) from dbo.OINM s1 where S1.Docdate <='[%1]'
select @Whse = Max(s2.Warehouse) from dbo.OINM S2 Where S2.Warehouse = '[%2]'

Select @Whse as 'Warehouse', a.Itemcode, max(a.Dscription) as ItemName,sum(b.OpeningBalance) as OpeningBalance, sum(sum(a.Del)-sum(a.Ret)) As Withdrawal.


(Select i.InvntryUom from OITM i where i.ItemCode=a.Itemcode) as UOM

from(select T2.Whscode, T1.Itemcode, T1.Dscription,Sum(T1.Quantity) as Del
From [dbo].[ODLN]  T0 INNER JOIN [dbo].[DLN1]  T1 ON T0.DocEntry = T1.DocEntry INNER JOIN [dbo].[OWHS]  T2 ON T0.Filler = T2.WhsCode
Where T0.DocDate >= @FromDate and T0.DocDate <= @ToDate and T0.Warehouse = @Whse
Group By T2.Whscode,T1.ItemCode,T1.Dscription

Union All

select T2.Whscode, T1.Itemcode, T1.Dscription, sum(T1.Quantity) as Ret
From [dbo].[ORDN]  T0 INNER JOIN [dbo].[RDN1]  T1 ON T0.DocEntry = T1.DocEntry INNER JOIN [dbo].[OWHS]  T2 ON T0.Filler = T2.WhsCode
here T0.DocDate >= @FromDate and T0.DocDate <= @ToDate and T0.Warehouse = @Whse
Group By T2.Whscode,T1.ItemCode,T1.Dscription)a,

(Select N1.Warehouse, N1.Itemcode, N1.Dscription, (sum(N1.inqty)-sum(n1.outqty))as OpeningBalance, 0 as INq, 0 as OUT
From dbo.OINM N1
Where N1.DocDate < @FromDate and N1.Warehouse = @Whse
Group By N1.Warehouse,N1.ItemCode,N1.Dscription)b,dbo.OITM I1

where a.ItemCode=I1.ItemCode=b.ItemCode
Group By a.Itemcode Having sum(a.Del) - sum(a.Ret) > 0
Order By a.Itemcode


Viewing all articles
Browse latest Browse all 2756

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>