title: Group Data using SQL "Group By" function in Excel VBA
body: <p>I have two tables (1&amp;2) that should be merged into a third (3) one.</p>
  
  <p>Table1: F_Number, A_Number, A_Weight<br>
  Table2: A_Number, A_Country<br>
  Table3: F_Number, A_Country, A_Weight</p>
  
  <p>The thrid table should be grouped by F_Number summing up A_Weight where A_Country has the same value. The joining of the tables works fine so far:</p>
  
  <pre><code>Dim strSQL As String
  Dim Conn As New ADODB.Connection
  Dim mrs As New ADODB.Recordset
  Dim DBPath As String
  Dim sconnect As String
  
  DBPath = ThisWorkbook.FullName
  sconnect = "Provider=MSDASQL.1;DSN=Excel Files;DBQ=" &amp; DBPath &amp; ";HDR=Yes';"
  
  Conn.Open sconnect
      strSQL = "Select [Table1$].[F_Number], [Table2$].[A_Country], [Table1$].[A_Weight] From [Table1$] Inner Join [Table2$] On [Table2$].[A_Number]=[Table1$].[A_Number]"
      mrs.Open strSQL, Conn
      ActiveSheet.Range("A2").CopyFromRecordset mrs
      mrs.Close
  Conn.Close
  </code></pre>
  
  <p>The Result is a table like this:</p>
  
  <p>F_Number; A_country; A_Weight<br>
  F_1; US; 10%<br>
  F_1: US; 10%<br>
  F_1; UK; 80%<br>
  F_2; UK; 100%</p>
  
  <p>I want this table to be grouped by "A_Weight" like this:</p>
  
  <p>F_Number; A_country; A_Weight<br>
  F_1; US; 20%<br>
  F_1; UK; 80%<br>
  F_2; UK; 100%</p>
  
  <p>I do not know much about SQL, but what I tried so far is to sum up A_Weight and Group the result by F_Number, which gives me an error message. I am using a german office version, thus I can only try to translate the error: "Automatization Error". I am still thinking it should work something like this.</p>
  
  <p>Here is my <strong>non-working</strong> code for the SQL-String:</p>
  
  <pre><code>strSQL = "Select [Table1$].[F_Number], [Table2$].[A_Country], Sum([Table1$].[A_Weight]) From [Table1$] Inner Join [Table2$] On [Table2$].[A_Number]=[Table1$].[A_Number] Group By [Table1$].[F_Number]"
  </code></pre>