GROUP BY

You can use the GROUP BY clause without using a group function in the select list.
Using a GROUP BY indicates that there will be multiple rows returned. When you do not use the GROUP BY clause you are treating the whole table as a single group.
You can use a "GROUP BY" clause to define a total query


SELECT last_name, sales 
FROM customer
GROUP BY
ORDER BY


The group by clause can only be used in queries that contain at least one group function.
All columns retrieved from the database must be present in the group by clause.


(View > Totals) dialog
select count, groupby
Done for each field and gives the user several functions including the GROUP BY (the default that is used when totals are not selected).
the above should be added to query view



Using GROUP BY to group multiple columns

SELECT CustomerID, COUNT(ProductID) 
FROM SALES
GROUP BY CustomerID, DateSold




Using GROUP BY with ORDER BY

SELECT CustomerID, COUNT(ProductID) 
FROM SALES
GROUP BY CustomerID, DateSold
ORDER BY COUNT(ProductID)



What are Group Functions ?

Group functions are also called Total Functions or Aggregate Functions.
These can be used to perform mathematical calculations
They operate on several rows and are used to return a single value.


Group functions can be nested to a depth of 2.



AVG
COUNT
FIRST
LAST
MAX
MIN
SUM




© 2017 Better Solutions Limited. All Rights Reserved. © 2017 Better Solutions Limited

Top

PrevNext