title: SQL Server 2016 count similar rows as a column without duplicating query
body: <p>I have a SQL query that returns data similar to this pseudo-table:</p>
  
  <pre><code>| Name | Id1 | Id2 | Guid |
  |------+-----+-----+------|
  | Joe  | 1   | 1   | 1123 |
  | Joe  | 2   | 1   | 1123 |
  | Joe  | 3   | 1   | 1120 |
  | Jeff | 1   | 1   | 1123 |
  | Moe  | 3   | 42  | 1120 |
  </code></pre>
  
  <p>I would like to display an additional column on the output, listing the total number of records that have matching GUIDs to a given row, like this:</p>
  
  <pre><code>| Name | Id1 | Id2 | Guid | # Matching |
  +------+-----+-----+------+------------+
  | Joe  | 1   | 1   | 1123 | 3          |
  | Joe  | 2   | 1   | 1123 | 3          |
  | Joe  | 3   | 1   | 1120 | 2          |
  | Jeff | 1   | 1   | 1123 | 3          |
  | Moe  | 3   | 42  | 1120 | 2          |
  </code></pre>
  
  <p>I was able to accomplish this by joining the query with itself, and doing a count. However, the query is rather large and takes awhile to complete, is there any way I can accomplish this without joining the query with itself?</p>