title: SQL Server Divide Select top 1 Total Balance / Count of rows
body: <p>My issue is that the Balance is the sum of City. I'd like to divide the Select top 1 Balance from #temp by the number of counts.</p>
  <p>For example, my table is like</p>
  <pre><code>create table #temp
  (
  Source varchar(6),
  City varchar(20),
  Balance money
  )
  
  insert into #temp values ('NE1', 'Chicago', 1000.00)
  insert into #temp values ('NE2', 'Chicago', 1000.00)
  </code></pre>
  <p>So in the example above, I'd see a table output like:</p>
  <pre><code>Source    Account    Balance    RelativeBalance
  NE1       Chicago    1000       500
  NE2       Chicago    1000       500
  </code></pre>
  <p>The relative Balance then is the 1000 divided by the count of Chicago, 2.</p>
  <p>Note, there's not a split in the backend.</p>