title: In SQL, how to sum numerical values in one column based on string values in another column
body: <p>I'd like my procedure to return the total of <code>AcceptedProducts</code> by <code>PlantName</code>.</p>
  <p>Could someone help me to correct my procedure?</p>
  <pre><code>CREATE PROCEDURE spAcceptedByCountry @Year INT, @Month INT
  AS
      SELECT      CountryCode,
                  CountryName,
                  REPLACE(SUBSTRING([PlantName], CHARINDEX('-', [PlantName]), LEN([PlantName])), '-', '') AS [PlantName],
                  SUM(AcceptedProducts) AS AcceptedProducts 
      FROM        vAcceptedByCountry
      WHERE       YEAR(DateOfManufacture) = @Year AND MONTH(DateOfManufacture) = @Month
      GROUP BY    CountryCode,
                  CountryName,
                  PlantName,
                  AcceptedProducts
      ORDER BY    CountryCode;
  GO
  </code></pre>
  <p>Thank you for your help.
  Kind Regards.</p>