Hi
I am getting error - Column 'View_Capex_StepWiseApprovalDetail.EntryCode' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
ALTER VIEW [dbo].[View_CPX_Pivot] AS SELECT * FROM ( SELECT (Min(L.[EntryCode])) AS [PR Number] ,(select top 1 DATEDIFF(d,Min(L.[RequestDate]),Max(L.[ApprovalDate])) FROM [View_Capex_StepWiseApprovalDetail] A where A.EntryCode=L.EntryCode) as [Total Days] ,DATEDIFF(d,min(L.[RequestDate]),max(L.[ApprovalDate])) as [DaysToApprove] ,[LevelName] FROM [View_Capex_StepWiseApprovalDetail] L where l.EntryCode = 209 ) t PIVOT( MIN([DaysToApprove]) FOR [LevelName] IN ([Level 1], [Level 2], [Level 3], [Level 4], [Level 5], [Level 6], [Level 7], [Level 8], [Level 9], [Level 10], [Level 11], [Level 12]) ) AS pivot_table1 GO
Thanks