SELECT ... FROM relation-list WHERE tuple-boolean-condition GROUP BY grouping-attributes |
|
Here is the employee relation: SELECT fname, lname, sex, dno, salary FROM employee fname lname sex dno salary ------ -------- ------ ----------- --------- James Borg M 1 55000.00 Alicia Zelaya F 4 25000.00 Jennif Wallace F 4 43000.00 Ahmad Jabbar M 4 25000.00 John Smith M 5 30000.00 Frankl Wong M 5 40000.00 Ramesh Narayan M 5 38000.00 Joyce English F 5 25000.00 |
|
Employee relation: +--------+---------+-----+------+----------+ | fname | lname | dno | sex | salary | +--------+---------+-----+------+----------+ | James | Borg | 1 | M | 55000.00 | | Alicia | Zelaya | 4 | F | 25000.00 | | Jennif | Wallace | 4 | F | 43000.00 | | Ahmad | Jabbar | 4 | M | 25000.00 | | Joyce | English | 5 | F | 25000.00 | | John | Smith | 5 | M | 30000.00 | | Frankl | Wong | 5 | M | 40000.00 | | Ramesh | Narayan | 5 | M | 38000.00 | +--------+---------+-----+------+----------+ I highlighted the groups formed using (dno, sex) values |
|
|
|
SELECT sum(salary) /* Omit dno, sex */ FROM employee GROUP BY dno, sex SUM(SALARY) ----------- 25000 55000 108000 68000 25000 |
You cannot tell what is the meaning of the output values...