product performance grouped kpi improvements
This commit is contained in:
@@ -382,6 +382,22 @@ ORDER BY StockDate, ProductCode, ColorCode, YakaKodu
|
||||
func productPerformancePriceSQL() string {
|
||||
return `
|
||||
;WITH ProductCodes AS (
|
||||
SELECT DISTINCT ItemCode
|
||||
FROM cdItem WITH(NOLOCK)
|
||||
WHERE ItemTypeCode = 1
|
||||
AND (
|
||||
LEN(LTRIM(RTRIM(ItemCode))) = 13
|
||||
AND (
|
||||
ItemCode LIKE 'S%'
|
||||
OR ItemCode LIKE 'O%'
|
||||
OR ItemCode LIKE 'N%'
|
||||
OR ItemCode LIKE 'X%'
|
||||
OR ItemCode LIKE 'I%'
|
||||
OR ItemCode LIKE 'A%'
|
||||
)
|
||||
)
|
||||
AND (@p1 = '' OR ItemCode LIKE @p1 + '%')
|
||||
UNION
|
||||
SELECT DISTINCT ItemCode
|
||||
FROM trPriceListLine WITH(NOLOCK)
|
||||
WHERE ItemTypeCode = 1
|
||||
@@ -460,6 +476,83 @@ Cost AS (
|
||||
)
|
||||
SELECT
|
||||
pc.ItemCode,
|
||||
ItemDescription = dbo.HG_Temizlik(ISNULL((
|
||||
SELECT ItemDescription
|
||||
FROM cdItemDesc WITH(NOLOCK)
|
||||
WHERE cdItemDesc.ItemTypeCode = 1
|
||||
AND cdItemDesc.ItemCode = pc.ItemCode
|
||||
AND cdItemDesc.LangCode = 'TR'
|
||||
), SPACE(0))),
|
||||
Kategori = dbo.HG_Temizlik(ISNULL((
|
||||
SELECT AttributeDescription
|
||||
FROM cdItemAttributeDesc WITH(NOLOCK)
|
||||
WHERE cdItemAttributeDesc.ItemTypeCode = 1
|
||||
AND cdItemAttributeDesc.AttributeTypeCode = 44
|
||||
AND cdItemAttributeDesc.AttributeCode = (
|
||||
SELECT TOP 1 AttributeCode
|
||||
FROM prItemAttribute WITH(NOLOCK)
|
||||
WHERE AttributeTypeCode = 44
|
||||
AND prItemAttribute.ItemTypeCode = 1
|
||||
AND prItemAttribute.ItemCode = pc.ItemCode
|
||||
)
|
||||
AND cdItemAttributeDesc.LangCode = 'TR'
|
||||
), SPACE(0))),
|
||||
AskiliYan = dbo.HG_Temizlik(ISNULL((
|
||||
SELECT AttributeDescription
|
||||
FROM cdItemAttributeDesc WITH(NOLOCK)
|
||||
WHERE cdItemAttributeDesc.ItemTypeCode = 1
|
||||
AND cdItemAttributeDesc.AttributeTypeCode = 45
|
||||
AND cdItemAttributeDesc.AttributeCode = (
|
||||
SELECT TOP 1 AttributeCode
|
||||
FROM prItemAttribute WITH(NOLOCK)
|
||||
WHERE AttributeTypeCode = 45
|
||||
AND prItemAttribute.ItemTypeCode = 1
|
||||
AND prItemAttribute.ItemCode = pc.ItemCode
|
||||
)
|
||||
AND cdItemAttributeDesc.LangCode = 'TR'
|
||||
), SPACE(0))),
|
||||
UrunIlkGrubu = dbo.HG_Temizlik(ISNULL((
|
||||
SELECT AttributeDescription
|
||||
FROM cdItemAttributeDesc WITH(NOLOCK)
|
||||
WHERE cdItemAttributeDesc.ItemTypeCode = 1
|
||||
AND cdItemAttributeDesc.AttributeTypeCode = 42
|
||||
AND cdItemAttributeDesc.AttributeCode = (
|
||||
SELECT TOP 1 AttributeCode
|
||||
FROM prItemAttribute WITH(NOLOCK)
|
||||
WHERE AttributeTypeCode = 42
|
||||
AND prItemAttribute.ItemTypeCode = 1
|
||||
AND prItemAttribute.ItemCode = pc.ItemCode
|
||||
)
|
||||
AND cdItemAttributeDesc.LangCode = 'TR'
|
||||
), SPACE(0))),
|
||||
UrunAnaGrubu = dbo.HG_Temizlik(ISNULL((
|
||||
SELECT AttributeDescription
|
||||
FROM cdItemAttributeDesc WITH(NOLOCK)
|
||||
WHERE cdItemAttributeDesc.ItemTypeCode = 1
|
||||
AND cdItemAttributeDesc.AttributeTypeCode = 1
|
||||
AND cdItemAttributeDesc.AttributeCode = (
|
||||
SELECT TOP 1 AttributeCode
|
||||
FROM prItemAttribute WITH(NOLOCK)
|
||||
WHERE AttributeTypeCode = 1
|
||||
AND prItemAttribute.ItemTypeCode = 1
|
||||
AND prItemAttribute.ItemCode = pc.ItemCode
|
||||
)
|
||||
AND cdItemAttributeDesc.LangCode = 'TR'
|
||||
), SPACE(0))),
|
||||
UrunAltGrubu = dbo.HG_Temizlik(ISNULL((
|
||||
SELECT AttributeDescription
|
||||
FROM cdItemAttributeDesc WITH(NOLOCK)
|
||||
WHERE cdItemAttributeDesc.ItemTypeCode = 1
|
||||
AND cdItemAttributeDesc.AttributeTypeCode = 2
|
||||
AND cdItemAttributeDesc.AttributeCode = (
|
||||
SELECT TOP 1 AttributeCode
|
||||
FROM prItemAttribute WITH(NOLOCK)
|
||||
WHERE AttributeTypeCode = 2
|
||||
AND prItemAttribute.ItemTypeCode = 1
|
||||
AND prItemAttribute.ItemCode = pc.ItemCode
|
||||
)
|
||||
AND cdItemAttributeDesc.LangCode = 'TR'
|
||||
), SPACE(0))),
|
||||
CostPriceUsd = ISNULL(c.CostPriceUsd, 0),
|
||||
BasePriceUsd = ISNULL(bp.BasePriceUsd, 0),
|
||||
BasePriceTry = ISNULL(bp.BasePriceTry, 0),
|
||||
|
||||
Reference in New Issue
Block a user