Hi All,
Please help me here.
I run this sql query and below is the result:
*******************************************************************************************************8
select distinct productiondate,CostCenterKey, adr.AEMainCategoryKey,
Sum(adr.DurationDayFrac*adr.FixedCashCostAE) over(partition by AEMainCategoryKey) / Sum(adr.DurationDayFrac*adr.FixedCashCostAE) over() AELossMagnitude
FROM [OperationsDB].[Analysis].[AEDailyReportings] adr
WHERE adr.DurationDayFrac != 0
AND adr.ProductionDate <= getdate()
AND adr.ProductionDate >= '2017-01-01'
AND adr.SiteName in ('Ludwigshafen','Schwarzheide','Antwerpen')
AND AreaIsCurrent = 'true'
and productiondate = '2022-01-01'
and CostCenterKey = '100030'
group by productiondate,AEMainCategoryKey,CostCenterKey,DurationDayFrac,FixedCashCostAE
******************************************************************************************************
Result of the highlighted query:
But i have to remove the 2 filters productiondate = '2022-01-01' and CostCenterKey = '100030' to make a generic query.
So now when i execute the below query the results are not matching.
*****************************************************************************
select productiondate,CostCenterKey,AEMainCategoryKey,AELossMagnitude
from
(
select distinct productiondate,CostCenterKey, adr.AEMainCategoryKey,
Sum(adr.DurationDayFrac*adr.FixedCashCostAE) over(partition by AEMainCategoryKey)*100 / Sum(adr.DurationDayFrac*adr.FixedCashCostAE) over() AELossMagnitude
FROM [OperationsDB].[Analysis].[AEDailyReportings] adr
WHERE adr.DurationDayFrac != 0
AND adr.ProductionDate <= getdate()
AND adr.ProductionDate >= '2017-01-01'
AND adr.SiteName in ('Ludwigshafen','Schwarzheide','Antwerpen')
AND AreaIsCurrent = 'true'
group by productiondate,AEMainCategoryKey,CostCenterKey,DurationDayFrac,FixedCashCostAE
) a
where a.productiondate = '2022-01-01'
and a.CostCenterKey = '100030'
*****************************************************************************
Result of the above query"
Please see below.
Please suggest me where am i going wrong.
Thanks
Faizan