Database Toolbox | ![]() ![]() |
Use the Group by function to organize query results by field in the order you specify. The Group by results contain only unique occurrences (no rows that have identical data). You can also use the Having function to further restrict the Group by results.
After selecting Fields in the Visual Query Builder dialog box, click Group by in Advanced query options. The Group By Clauses dialog box appears.
Group By Clauses Dialog Box
1
means group by that field first, 2
means group by that field second, etc.To remove a clause, select the clause and then click Delete. Use Ctrl-click or Shift-click to select multiple clauses to delete.
Changes automatically update the Group key number for the other clauses.
The Group By Clauses dialog box closes. The SQL statement in the Visual Query Builder dialog box reflects the group-by clause.
Example Using Group By Clauses
This example retrieves sales volumes for January and February, organizing the results first for January sales, and then for February sales.
January
and February
from the salesVolume
table.January
, specify the Group key number value to be 1
and click Apply. For February
, specify the Group key number value to be 2
and click Apply (shown in example below).The Group By Clauses dialog box closes. The SQL statement in the Visual Query Builder dialog box reflects the group-by clause conditions you specified.
3000
, are grouped together.B
). There are three records in B
for which January sales are 3000
. These are not grouped together. In addition, for two of them, the February sales (column two) are the same, 2400
. By comparison, there are only two records in A
where January sales are 3000
, because using Group by only includes unique occurrences in the results.See Also
![]() | Subquery | Having | ![]() |