|
(The set may contain zero or one value, it is nevertheless a set )
(Therefore, since there are multiple groups , you will get multiple values or a group/set of values )
We must first form groups of employee tuples based on their DNO attribute (grouped by department number)
And then compute the average Salary :
DNO Avg +-----------+------------+ | 4 | 45000 | +-----------+------------+ | 5 | 55000 | +-----------+------------+ |
|
We must first form groups of employee tuples based on their "sex" attribute
And then compute the average Salary :
sex Avg +-----------+------------+ | M | 50000 | +-----------+------------+ | F | 50000 | +-----------+------------+ |
In that case, you will have "finer" (more smaller) groups.
We must first form groups of employee tuples based on their DNO and sex attributes (grouped by department number and sex)
And then compute the average Salary :
DNO sex Avg +--------+-----------+------------+ | 4 | M | 45000 | +--------+-----------+------------+ | 5 | M | 60000 | +--------+-----------+------------+ | 5 | F | 50000 | +--------+-----------+------------+ |
DNO sex Avg +--------+-----------+------------+ | 4 | M | 45000 | +--------+-----------+------------+ | 4 | F | 0 | <---- NOT the result !!! +--------+-----------+------------+ | 5 | M | 60000 | +--------+-----------+------------+ | 5 | F | 50000 | +--------+-----------+------------+ |
Keep this in mind when you do queries !!!
We must first form groups of employee tuples based on their DNO and sex attributes (grouped by department number and sex)
And then compute average Salary and count the SSN of employees:
DNO sex Avg Count +--------+-----------+------------+------+ | 4 | M | 45000 | 2 | +--------+-----------+------------+------+ | 5 | M | 60000 | 1 | +--------+-----------+------------+------+ | 5 | F | 50000 | 1 | +--------+-----------+------------+------+ |
is denoted as follows:
Although the
result set
will consist of
ONE single tuple (row) ,
the output of the set function
is
still a relation
It is a relation with one single tuple in it !!! |