feat(datamart): psi data has been added :D
This commit is contained in:
43
backend/prodSql/queries/datamart.activeArticles2.sql
Normal file
43
backend/prodSql/queries/datamart.activeArticles2.sql
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
This will be replacing activeArticles once all data is remapped into this query.
|
||||
make a note in the docs this activeArticles will go stale sooner or later.
|
||||
**/
|
||||
use [test1_AlplaPROD2.0_Read]
|
||||
|
||||
select a.Id,
|
||||
a.HumanReadableId as av,
|
||||
a.Alias as alias,
|
||||
p.LoadingUnitsPerTruck as loadingUnitsPerTruck,
|
||||
p.LoadingUnitsPerTruck * p.LoadingUnitPieces as qtyPerTruck,
|
||||
p.LoadingUnitPieces,
|
||||
case when i.MinQuantity IS NOT NULL then round(cast(i.MinQuantity as float), 2) else 0 end as min,
|
||||
case when i.MaxQuantity IS NOT NULL then round(cast(i.MaxQuantity as float),2) else 0 end as max
|
||||
from masterData.Article (nolock) as a
|
||||
|
||||
/* sales price */
|
||||
left join
|
||||
(select *
|
||||
from (select
|
||||
id,
|
||||
PackagingId,
|
||||
ArticleId,
|
||||
DefaultCustomer,
|
||||
ROW_NUMBER() OVER (PARTITION BY ArticleId ORDER BY ValidAfter DESC) AS RowNum
|
||||
from masterData.SalesPrice (nolock)
|
||||
where DefaultCustomer = 1) as x
|
||||
where RowNum = 1
|
||||
) as s
|
||||
on a.id = s.ArticleId
|
||||
|
||||
/* pkg instructions */
|
||||
left join
|
||||
masterData.PackagingInstruction (nolock) as p
|
||||
on s.PackagingId = p.id
|
||||
|
||||
/* stock limits */
|
||||
left join
|
||||
masterData.StockLimit (nolock) as i
|
||||
on a.id = i.ArticleId
|
||||
|
||||
where a.active = 1
|
||||
and a.HumanReadableId in ([articles])
|
||||
Reference in New Issue
Block a user