title: SQL Except Operator and with CTE to select all the items in 1st query but not in 2nd Query
body: <p>I am trying to get all the data in the 1st query below but except the data from the 2nd query below.</p>
  
  <p>Here 1st I am trying to select the unique data/distinct data by using <code>with cte</code> and <code>partition by</code>.</p>
  
  <p>I tried using except, but I get this error:</p>
  
  <blockquote>
    <p>Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.***</p>
  </blockquote>
  
  <pre><code>First query:
  
      With cte as
      (
          select 
              *, 
              row_number() over (partition by [Employee ID] order by [QTR] DESC, Wk desc) rownumber 
          from 
              tbl_HC
      )
      select * 
      from cte 
      where rownumber = 1
        and QTR = (Select max(QTR) from tbl_HC)
  
      Except
  
      --2nd query
      With cte as
      (
           select 
               *, 
               row_number() over (partition by [Employee ID] order by [QTR] DESC, Wk desc) rownumber 
           from  
               tbl_HC
      )
      select * 
      from cte 
      where rownumber = 1
          and Wk= (
          Select max(Wk) from tbl_HC
          where QTR = (Select max(QTR) from tbl_HC))`
  </code></pre>