consider this sql
CREATE VIEW [dbo].[MyView1] ([ID],[VisitDate],[StartDate] ,[EndDate],[MyCount])
WITH SCHEMABINDING
AS
SELECT id, VisitDate,dateadd(dd,-10,VisitDate),dateadd(dd,10,VisitDate),
count_BIG(*)as MyCount
FROM dbo.Visits2
group by id,VisitDate
I am trying to create a clustered index on this view on id,VisitDate.I am getting the following error.
Cannot create the clustered index ‘IX_!!’ on view ‘CI_DB.dbo.MyView4’
because the select list of the view contains an expression on result of
aggregate function or grouping column.
Consider removing expression on result of aggregate function or
grouping column from select list.
Changed the sql to
Seems like you cant specify a direct value like 10 inside the function and group by clause.Now it works!!