Hi. If you want to count the number of records use the Count function to do so. It is more useful to group the records together (by Dept, for example) so that the count is not just a single count of all the records but a meaningful count of the number within that specific grouping:
- SELECT Dept, Count(*) as RecCount from Sometable GROUP BY Dept;
If you want to sum a field, as in your example, the approach is similar:
- SELECT Dept, Sum([Quantity]) as NumberSold, Count(*) as RecCount from Sometable GROUP BY Dept;
On a related but different application which does not involve SQL, if you wanted to have an unbound control on a form or a report do the sum of a field called Quantity (assumed to be a part of the underlying table or query) you would set the control's control source property to
I wonder if it is mixing these two syntaxes up which is causing at least part of your difficulties?
-Stewart