title: Need to create subquery in Access 2016 that gives a distinct count
body: <p>So I am trying to create a query that will return the total weight of food taken out of our food cupboard by students (I work at a university food cupboard) and I am able to get it to give me all of the totals I need except for a count of distinct students that come in. Basically, I need it to give me the number of different students that come in instead of the number of transactions it's giving me right now. Anyone out there know how to fix it? Current code is below:</p>
  
  <p><code>Student_ID</code> is the field that I need the subquery on if I'm correct...</p>
  
  <pre><code>SELECT DISTINCTROW 
      Format$([Transaction Table].[Date],'mmmm yyyy') AS [Month], 
      Sum([Transaction Table].Weight) AS [Total Weight], 
      Count(*) AS [Total Transaction], 
      Count([Transaction Table].Student_ID) AS [Unique Customers]
  FROM [Transaction Table]
  GROUP BY 
      Format$([Transaction Table].[Date],'mmmm yyyy'), 
      Year([Transaction Table].[Date])*12+DatePart('m',[Transaction Table].[Date])-1;
  </code></pre>