title: COUNT_BIG in Indexed View
body: <pre><code>CREATE TABLE test2 (
  id INTEGER,
  name VARCHAR(10),
  family VARCHAR(10),
  amount INTEGER)
  
  CREATE VIEW dbo.test2_v WITH SCHEMABINDING 
  AS
  SELECT id, SUM(amount) as amount
  -- , COUNT_BIG(*) as tmp
  FROM dbo.test2 
  GROUP BY id
  
  CREATE UNIQUE CLUSTERED INDEX vIdx ON test2_v(id)
  </code></pre>
  
  <p>I have error with this code:</p>
  
  <blockquote>
    <p>Cannot create index on view
    'test.dbo.test2_v' because its select
    list does not include a proper use of
    COUNT_BIG. Consider adding
    COUNT_BIG(*) to select list.</p>
  </blockquote>
  
  <p>I can create view like this:</p>
  
  <pre><code>CREATE VIEW dbo.test2_v WITH SCHEMABINDING 
      AS
      SELECT id, SUM(amount) as amount, COUNT_BIG(*) as tmp
      FROM dbo.test2 
      GROUP BY id
  </code></pre>
  
  <p>But I'm just wondering what is purpose of this column in this case?</p>