title: Rank function () to work as 1 or 0 in SQL Server
body: <p>I needed help with finding a way of doing the following in SQL Server.</p>
  
  <p>Basically, in Excel, I can write something like:</p>
  
  <pre><code>IF(COUNTIF(A:A:A2) &gt; 1:1:0))
  </code></pre>
  
  <p>What this Excel code does is that IF IT finds a customer number repeating in the customer number column, the formula returns 1 else 0.</p>
  
  <p>I included this in my code</p>
  
  <pre><code>Select
      Contract_nr,
      Customer_number,
      Rank()OVER(ORDER BY customer_number) AS tester
      Productname,
      Sales_date
  From 
      table namn
  </code></pre>
  
  <p>The <code>rank()</code> returns 1100, 1105 and so on...</p>
  
  <p>How can I make IT so my tester column returns instead 1 or 0 IF a customer number repeats?</p>