title: SQL Server: Swap two lines depending on criteria
body: <p>Suppose a table named <strong>Sales</strong> with this data in SQL Server</p>
  
  <pre><code>--------------------------------------------
  Id      |  Customer_Id      |  Rate  |  Pid
  --------------------------------------------
  180     |  374              |  1     |  A01
  277     |  374              |  0     |  NULL
  346     |  785              |  1     |  D03
  476     |  785              |  0     |  NULL
  1821    |  1234             |  0     |  E07
  25951   |  1951             |  1     |  K73
  </code></pre>
  
  <p>How update my table to swap <strong>Rate</strong> and <strong>Pid</strong> values between lines having same customer_Id, so I can have a result like this:</p>
  
  <pre><code>--------------------------------------------
  Id      |  Customer_Id      |  Rate  |  Pid
  --------------------------------------------
  180     |  374              |  0     |  NULL
  277     |  374              |  1     |  A01
  346     |  785              |  0     |  NULL
  476     |  785              |  1     |  D03
  1821    |  1234             |  0     |  E07
  25951   |  1951             |  1     |  K73
  </code></pre>
  
  <p>How can I achieve this?</p>