Sybase 2 Barcode Reader User Manual


 
Using SQL Select
134 DataWindow .NET
4 Define limiting (Where view), grouping (Group view), and limiting
groups (Having view) criteria as appropriate.
5 Click the SQL Select button to return to the DataWindow painter.
Defining GROUP BY
criteria
You can group the retrieved rows by specifying groups that correspond to the
GROUP BY clause in the SELECT statement. This grouping happens before the
data is retrieved into the DataWindow object. Each group is retrieved as one
row into the DataWindow object.
For example, if in the
SELECT statement you group data from the Employee
table by department ID, you will get one row back from the database for every
department represented in the Employee table. You can also specify computed
columns, such as total and average salary, for the grouped data. This is the
corresponding
SELECT statement:
SELECT dept_id, sum(salary), avg(salary)
FROM employee
GROUP BY dept_id
If you specify this with the Employee table in the EAS Demo DB, you get five
rows back, one for each department.
For more about
GROUP BY, see your DBMS documentation.
To define GROUP BY criteria:
1 Click the Group tab to make the Group view available (or select
View>Group if the Group view is not currently displayed).
The columns in the tables you selected display in the left side of the Group
view. You might need to scroll to see your selections.
2 Drag the first column you want to group onto the right side of the Group
view.
This specifies the column for grouping. Columns are grouped in the order
in which they are displayed in the right side of the Group view.