title: SQL Query - ORDER BY
body: <pre><code>rs.Open "SELECT [A$].Security,[A$].Name,SUM([A$].[Price]) FROM [A$] INNER JOIN [B$] ON [A$].Security = [B$].ID GROUP BY [A$].Security,[A$].Description", cn, adOpenKeyset, adLockReadOnly
  </code></pre>
  
  <p>The result that I get from this query does not align or match the respective ID in sheet B. For Example :- A is the master worksheet from where I aggregate records matching the ID of B and Security of A. Now, A might have multiple instances of B's ID having different price, which is the reason why I aggregate. My question is that when I paste the record set data, I see that the aggregated price value is not pasted in front of the ID in B i.e I want them to be ordered according to the ID in B and ORDER BY also doesn't work, throwing an error that [B$].ID is not a part of the aggregate function. Can someone hint on how can it be done ?</p>