title: Using If statement with a Row_Number then +1
body: <p>I have tried creating the code below but it didn't work for me.</p>
  <p>what I'm trying to do is use Row_number however check if the column MP =' Yes' then +1 to the Row_number value if it does otherwise just give me the Row_number.</p>
  <pre><code>  SELECT
   [Key]
  ,[Key2]
  ,MP
  ,OriginalOrder = ROW_NUMBER() OVER(Partition by [Key] ORDER BY  [Key],[Key2])
  ,IIF(MP = 'Yes' , ROW_NUMBER() OVER(Partition by [Key] ORDER BY  [Key],[Key2])+1,ROW_NUMBER() OVER(Partition by [Key] ORDER BY  [Key],[Key2]))what_i_have_tried
  FROM
  cte_RowNumbertest
  ORDER BY
  1,2
  </code></pre>
  <p><a href="https://i.stack.imgur.com/O4B6s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/O4B6s.png" alt="enter image description here" /></a></p>