title: Order of query execution
body: <p>I have a query of the basic structure</p>
  
  <pre><code>with cte1 as (Select *query on tbl1*)
  ,cte2 as (select *query on tbl1*
        Exception join cte1 )
  
  Select * from cte1
  union all
  Select * from cte2
  </code></pre>
  
  <p>And I really have no idea whether I can be confident this will behave as expected - each of ctes produce similar rows, but would have different logic - I want cte1 to pass through the table with its logic, then cte2 to review the same table again, after cte1 has picked all the records that apply to it - will this work?</p>
  
  <p>Edit: Ok, I have created some data and outlined where I am concerned. I am not sure how to interpret philipxy's response with the above - I can understand from his response what to expect from cte1, but I do not fully understand what cte2 would be - does cte1 get "declared" before cte2, so that their values are locked in once the query begins?</p>
  
  <p><a href="https://i.stack.imgur.com/scJJt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/scJJt.png" alt="enter image description here"></a></p>