title: Create view with with statement
body: <p>How to create view with a with statement?
  I'm getting on error on it:</p>
  
  <pre><code>    WITH temp as (
  select uu.email, u.logintime, u.region, p.id as panelid, p.panelname, p.numberofdownloads, dimensionType + ' (' + dimensionValue + ')' as filter
  from stat_users u
  left join stat_panels p
  on u.id=p.sessionid
  left join stat_filters f
  on p.id=f.panelid
  left join users uu
  on uu.id=u.userid
  where uu.Organization = 'name' AND
       year(logintime) between 2015 and 2017
      and panelname is not  null
  )
  
  
  CREATE VIEW final as(
      select aa.email, aa.logintime, aa.region, aa.panelname, aa.numberofdownloads as downloads, case when len(aa.filters) &gt; 0 then left(aa.filters, len(aa.filters)-1) else '' end as filters
      from (
      Select distinct a.email, a.logintime, a.region, a.panelname, a.numberofdownloads,
                  (
                      Select b.filter + ', ' AS [text()]
                      From temp b
                      Where b.panelid=a.panelid
                      ORDER BY b.panelid
                      For XML PATH ('')
                  ) filters
      from temp a
      ) aa
  </code></pre>
  
  <p>)
  I'm getting such error :</p>
  
  <pre><code>&gt; Incorrect syntax near the keyword 'CREATE'. 'CREATE VIEW' must be the
  &gt; first statement in a query batch.
  </code></pre>
  
  <p>So, I need just to use Create view using select which based on WITH statement on Sql server 2014</p>