title: Your query does not include the specified expression. What does it mean and how do I fix it?
body: <p>When I add currency rate into this code Access tells me that <em>"Your query does not include the specified expression [Transaction details].[Currency code] = [Currencies].[Currency code] as part of an aggregate function."</em> What does it mean and how do I fix it?</p>
  
  <pre><code>SELECT [Sales structure].Cluster,
         [Sales structure].Country,
         [Transaction details].[Sales company code],
         [Sales structure].[Sales company name],
         Year([Transaction details].[YYYY-MM-DD])      AS [Year],
         Month([Transaction details].[YYYY-MM-DD])     AS [Month],
         Sum([Transaction details].[Sales volume LOC]) AS Sales,
         [Transaction details].[Customer code]
  FROM   Currencies
         RIGHT JOIN ([Sales structure]
                     RIGHT JOIN [Transaction details]
                       ON [Sales structure].[Sales company code] = [Transaction details].[Sales company code])
           ON Currencies.[Currency code] = [Transaction details].[Customer code]
  GROUP  BY [Sales structure].Cluster,
            [Sales structure].Country,
            [Transaction details].[Sales company code],
            [Sales structure].[Sales company name],
            Year([Transaction details].[YYYY-MM-DD]),
            Month([Transaction details].[YYYY-MM-DD]),
            [Transaction details].[Customer code],
            Currencies.[CUR/EUR]
  HAVING (( [Transaction details].[Currency code] = [Currencies].[Currency code] ))
  ORDER  BY Year([Transaction details].[YYYY-MM-DD]),
            Month([Transaction details].[YYYY-MM-DD]); 
  </code></pre>