title: recursive cte with ranking functions
body: <p>How to use ranking functions in recursive cte?
  Here's simple example showing how I'm trying to do:</p>
  
  <pre>with cte as (
    select 1 a, 1 b union all select 1, 2 union all select 2, 3 union all select 2, 4
  )
  , rcte (a, b, c, d) as (
    select a, b, cast(0 as int), 1 
    from cte
    union all
    select a, b, cast(ROW_NUMBER() over (partition by a order by b) as int), d+1
    from rcte
    where d &lt; 2
  )
  select * 
  from rcte
  where d=2
  order by a, b
  </pre>
  
  <p>Why there's no ranking? Show me my mistake pls</p>