Files
lst_v3/backend/prodSql/queries/datamart.inventory.sql
Blake Matthes eccaf17332
Some checks failed
Build and Push LST Docker Image / docker (push) Failing after 39s
feat(datamart): migrations completed remaining is the deactivation that will be ran by anylitics
2026-04-14 20:25:20 -05:00

44 lines
1.5 KiB
SQL

select
ArticleHumanReadableId as av
,ArticleAlias as alias
,round(sum(QuantityLoadingUnits),0) total_pallets
,round(sum(Quantity),0) as total_palletQTY
,round(sum(case when State = 0 then QuantityLoadingUnits else 0 end),0) avalible_Pallets
,round(sum(case when State = 0 then Quantity else 0 end),0) available_QTY
,sum(case when b.HumanReadableId = 864 then QuantityLoadingUnits else 0 end) as coa_Pallets
,sum(case when b.HumanReadableId = 864 then Quantity else 0 end) as coa_QTY
,sum(case when b.HumanReadableId <> 864 then QuantityLoadingUnits else 0 end) as held_Pallets
,sum(case when b.HumanReadableId <> 864 then Quantity else 0 end) as held_QTY
--,l.RunningNumber
/** should be in line **/
--,l.MachineLocation,l.MachineName,l.ProductionLotRunningNumber
/** should be in line **/
--,l.WarehouseDescription,l.LaneDescription
,articleTypeName
FROM [test1_AlplaPROD2.0_Read].[warehousing].[WarehouseUnit] as l
left join
(
SELECT [Id]
,[HumanReadableId]
,d.[Description]
,[DefectGroupId]
,[IsActive]
FROM [test1_AlplaPROD2.0_Read].[blocking].[BlockingDefect] as g
left join
[AlplaPROD_test1].dbo.[T_BlockingDefects] as d (nolock) on
d.IdGlobalBlockingDefect = g.HumanReadableId
) as b on
b.id = l.MainDefectId
where LaneHumanReadableId not in (20000,21000)
group by ArticleHumanReadableId,
ArticleAlias,
ArticleTypeName
--,l.RunningNumber
/** should be in line **/
--,l.MachineLocation,l.MachineName,l.ProductionLotRunningNumber
/** should be in line **/
--,l.WarehouseDescription,l.LaneDescription
order by ArticleHumanReadableId