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

Re: Inventory Query with movement and multiple selections

$
0
0

Dear Nagarajan

 

See below:

 

#WarehouseItem No.Item DescPrice in CZKOpening BalanceINOUTClosing
1WH100000
2WH13SPxxxxxx104.91080000
3WH13S 2Pxxxxxx299.83220000
4WH1COMP1000Pxxxxxx30.2210000

 

For the UoM form OITM, i can't seem to grasp the logic, when i just add your text, it is not working...

 

Now regarding the Item Group, i have managed to change the code as follow, no issue. But for the warehouse since i want the warehouse to appear in first column i do not know how to do:

 

Declare @Whse nvarchar(10)
Declare @FromDate DateTime
Declare @ToDate DateTime
Declare @Group1 nvarchar(10)
Declare @Group2 nvarchar(10)
Set @FromDate = (Select min(S0.Docdate) from dbo.OINM S0 where S0.Docdate >='[%0]')
Set @ToDate = (Select max(S1.Docdate) from dbo.OINM s1 where S1.Docdate <='[%1]')
Set @Group1 = (Select min(s2.ItmsGrpCod) from dbo.OITB S2 Where S2.ItmsGrpNam = '[%2]' )
Set @Group2 = (Select max(s3.ItmsGrpCod) from dbo.OITB S3 Where S3.ItmsGrpNam = '[%3]')
Set @Whse = (Select max(s4.Warehouse) from dbo.OINM S4 Where S4.Warehouse = '[%4]')
Select @Whse as 'Warehouse', a.Itemcode, max(a.Dscription) as 'Item Desc',max(a.Price) as 'Price in CZK', sum(a.[Opening Balance]) as [Opening Balance], sum(a.[IN]) as [IN], sum(a.OUT) as OUT, ((sum(a.[Opening Balance]) + sum(a.[IN])) - Sum(a.OUT)) as Closing from dbo.OITM I1 Left JOIN (Select N1.Warehouse, N1.Itemcode, N1.Dscription,N1.Price, (sum(N1.inqty)-sum(n1.outqty)) as [Opening Balance], 0 as [IN], 0 as OUT
From dbo.OINM N1
Where N1.DocDate < @FromDate and N1.Warehouse = @Whse
Group By N1.Warehouse,N1.ItemCode,N1.Dscription,N1.Price
Union All
select N1.Warehouse, N1.Itemcode, N1.Dscription,N1.price, 0 as [Opening Balance], sum(N1.inqty) as [IN], 0 as OUT
From dbo.OINM N1
Where N1.DocDate >= @FromDate and N1.DocDate <= @ToDate and N1.Inqty >0 and N1.Warehouse = @Whse
Group By N1.Warehouse,N1.ItemCode,N1.Dscription,N1.price
Union All
select N1.Warehouse, N1.Itemcode, N1.Dscription,N1.price, 0 as [Opening Balance], 0 as [IN], sum(N1.outqty) as OUT
From dbo.OINM N1
Where N1.DocDate >= @FromDate and N1.DocDate <=@ToDate and N1.OutQty > 0 and N1.Warehouse = @Whse
Group By N1.Warehouse,N1.ItemCode,N1.Dscription,N1.price) a ON a.ItemCode=I1.ItemCode
where  I1.ItmsGrpCod >= @Group1 and I1.ItmsGrpCod <= @Group2
Group By a.Itemcode
Order By a.Itemcode

Viewing all articles
Browse latest Browse all 9610

Trending Articles



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