title: Concatenating a List of of sites and count of occurrences into a column
body: <p>Using this page:  <a href="https://stackoverflow.com/questions/2046037/sql-server-can-i-comma-delimit-multiple-rows-into-one-column">Can I Comma Delimit Multiple Rows Into One Column?</a></p>
  
  <p>... I've been able to come up with results such as this:</p>
  
  <p><img src="https://i.stack.imgur.com/lVyeD.png" alt="enter image description here"></p>
  
  <p>Using this query:</p>
  
  <pre><code>SELECT
      [Client ID],
      STUFF((SELECT ', ' + [Location (counts)]
             FROM (
                  SELECT TOP 100 PERCENT [Client ID]
                      , ltrim(str([Store Num])) + ' (' + ltrim(str(count([Store Num]))) + ') ' [Location (counts)]
                  FROM @tbl_coreData
                  GROUP BY [Store Num], [Client ID]
                  ORDER BY COUNT([Store Num]) DESC) tblThis 
             WHERE ([Store Num] = Result.[Store Num] 
               AND [Client ID] = Result.[Client ID]) 
             FOR XML PATH ('')),1,1,'') AS BATCHNOLIST
  FROM @tbl_coreData AS Result
  GROUP BY [Client ID], [Store Num]
  </code></pre>
  
  <p>I want the list to be ordered by The count of occurrences (the number in parenthesis). My attempt at this was the </p>
  
  <pre><code>SELECT TOP 100 PERCENT 
      [Client ID]
  </code></pre>
  
  <p>and </p>
  
  <pre><code>ORDER BY COUNT([Store Num]) DESC
  </code></pre>
  
  <p>but this didn't work.</p>
  
  <p>How can I make the concatenated values be presented in order of descending occurrence?</p>
  
  <p>As always, all help is welcome and appreciated.</p>