May-16-2019, 11:42 AM
From Database i am able to do it by adding Zeros , unable to do it in python.
Select * from #FactSalesQuota
Select * from #FactSalesQuota
SalesamountQuota CalendarYear Employeekey 28000.00 2010 272 308000.00 2011 272 582000.00 2012 272 387000.00 2013 272 367000.00 2010 281 3037000.00 2011 281 4822000.00 2012 281 2936000.00 2013 281 637000.00 2010 282 3440000.00 2011 282 478000.00 2010 296 1209000.00 2012 296
CREATE TABLE #CalendarSales_final (SalesamountQuota DECIMAL(20,4),CalendarYear INT,Employeekey INT) SELECT Distinct Identity(INT,1,1) Rid,EmployeeKey INTO #temp FROM FactSalesQuota SELECT DISTINCT Calendaryear INTO #dates FROM FactSalesQuota DECLARE @i INT,@j INT=1,@Emp INT SELECT @i =Rid FROM #temp WHILE @j<=@i Begin SELECT @emp=EmployeeKey FROM #temp where Rid=@j INSERT INTO #CalendarSales_final SELECT ISNULL(C.salesamountQuota,0)SalesamountQuota, d.*,@emp FROM FactSalesQuota c Right join #Dates as d ON c.Calendaryear=d.Calendaryear and EmployeeKey in (SELECT t. EmployeeKey FROM #temp as t WHERE Rid=@j) Set @j=@j+1 end SELECT * FROM #CalendarSales_final