48 lines
1.7 KiB
Transact-SQL
48 lines
1.7 KiB
Transact-SQL
select
|
|
x.idartikelVarianten as article,
|
|
x.ArtikelVariantenAlias as alias
|
|
--x.Lfdnr as RunningNumber,
|
|
,round(sum(EinlagerungsMengeVPKSum),2) as total_pallets
|
|
,sum(EinlagerungsMengeSum) as total_palletQTY
|
|
,round(sum(VerfuegbareMengeVPKSum),0) as available_Pallets
|
|
,sum(VerfuegbareMengeSum) as available_QTY
|
|
,sum(case when c.Description LIKE '%COA%' then GesperrteMengeVPKSum else 0 end) as coa_Pallets
|
|
,sum(case when c.Description LIKE '%COA%' then GesperrteMengeSum else 0 end) as coa_QTY
|
|
,sum(case when c.Description NOT LIKE '%COA%' or x.IdMainDefect = -1 then GesperrteMengeVPKSum else 0 end) as held_Pallets
|
|
,sum(case when c.Description NOT LIKE '%COA%' or x.IdMainDefect = -1 then GesperrteMengeSum else 0 end) as held_QTY
|
|
,sum(case when x.WarenLagerLagerTyp = 8 then VerfuegbareMengeSum else 0 end) as consignment_qty
|
|
,IdProdPlanung as lot
|
|
----,IdAdressen,
|
|
,x.AdressBez
|
|
,x.IdLagerAbteilung as locationId
|
|
,x.LagerAbteilungKurzBez as laneDescription
|
|
,x.IdWarenlager as warehouseId
|
|
,x.WarenLagerKurzBez as warehouseDescription
|
|
--,*
|
|
from [AlplaPROD_test1].dbo.[V_LagerPositionenBarcodes] (nolock) x
|
|
|
|
left join
|
|
[AlplaPROD_test1].dbo.T_EtikettenGedruckt as l(nolock) on
|
|
x.Lfdnr = l.Lfdnr AND l.Lfdnr > 1
|
|
|
|
left join
|
|
|
|
(SELECT *
|
|
FROM [AlplaPROD_test1].[dbo].[T_BlockingDefects] where Active = 1) as c
|
|
on x.IdMainDefect = c.IdBlockingDefect
|
|
/*
|
|
The data below will be controlled by the user in excell by default everything will be passed over
|
|
IdAdressen = 3
|
|
*/
|
|
where /*IdArtikelTyp = 1 and */x.IdWarenlager not in (6, 1)
|
|
|
|
group by x.idartikelVarianten, ArtikelVariantenAlias, c.Description
|
|
--,IdAdressen
|
|
,x.AdressBez
|
|
,IdProdPlanung
|
|
,x.IdLagerAbteilung
|
|
,x.LagerAbteilungKurzBez
|
|
,x.IdWarenlager
|
|
,x.WarenLagerKurzBez
|
|
--, x.Lfdnr
|
|
order by x.IdArtikelVarianten |