Description
To get facings by group name and serving type
Query :
To get facings by group name and serving type
Query :
SELECT CONVERT(CHAR(7), D.SurveyDate, 120) AS Month,A.ClientName,A.GroupName,A.ServingTypeName,A.SKU,A.Product,COUNT(B.ProductId)Facings
FROM vwProductList A
JOIN AssetPurityProduct B ON A.ProductId = B.ProductId
JOIN AssetPurity C ON B.AssetPurityId = C.AssetPurityId
JOIN Survey D ON D.SessionUid = C.SessionUid
WHERE B.IsDeleted = '0'
AND C.IsDeleted = '0'
AND D.IsDeleted = '0'
AND Type <> 'POP'
AND Product NOT IN ('Foreign','Empty')
AND C.ClientId IN ('205')
AND D.SurveyDateTime >= '2025-01-01'
GROUP BY CONVERT(CHAR(7), D.SurveyDate, 120),A.ClientName,A.GroupName,A.ServingTypeName,A.SKU,A.Product
ORDER BY Month,ClientName,GroupName ASC
--------------------------------------------------