title: How to SUM many rows into 1 row in SQL Server?
body: <p>The following is my syntax</p>
  
  <pre><code>with AA as 
  (
    select distinct Store_Code, sum([Transactions]) as totaltrans
    from CRM_RETAIL_SUMMARY
    where Store_Code in ('L43','J62','L45','UA2','A35','949','C50','L44','Y45')
      and Trans_Hdr_Sale_Date BETWEEN '2018-12-1' AND '2018-12-31'
    group by Transactions, Store_Code
  ),
  BB as 
  ( 
    select distinct[Store_Code] as storecode from CRM_RETAIL_SUMMARY
  )
  select AA.totaltrans, BB.storecode
  from AA
  inner join BB on AA.Store_Code = BB.storecode
  </code></pre>
  
  <p>and then the result shows this:</p>
  
  <pre><code>storecode   totaltrans
  ----------------------
  A35          65
  A35          76
  A35          48
  A35          62
  A35          56
  UA2           5
  UA2           6
  UA2           8
  UA2          15
  UA2           9
  UA2          16
  949          16
  949          29
  949          55
  </code></pre>
  
  <p>But I want to SUM each of the storecode like the following but I don't know how:</p>
  
  <pre><code>storecode  totaltrans
  ---------------------
  A35         307 
  UA2          59
  </code></pre>
  
  <p>Thank you for all answers</p>