The employee relation:
ssn fname lname sex dno
--------- ------ -------- --- -----------
123456789 John Smith M 5
333445555 Frankl Wong M 5
999887777 Alicia Zelaya F 4
987654321 Jennif Wallace F 4
666884444 Ramesh Narayan M 5
453453453 Joyce English F 5
987987987 Ahmad Jabbar M 4
888665555 James Borg M 1
1. Execute the basic query
SELECT *
FROM employee
WHERE sex = 'M'
Result:
ssn fname lname sex dno
--------- ------ -------- --- -----------
123456789 John Smith M 5
333445555 Frankl Wong M 5
666884444 Ramesh Narayan M 5
987987987 Ahmad Jabbar M 4
888665555 James Borg M 1
2. Group the selected tuples by DNO:
ssn fname lname sex dno
--------- ------ -------- --- -----------
123456789 John Smith M 5
333445555 Frankl Wong M 5
666884444 Ramesh Narayan M 5
987987987 Ahmad Jabbar M 4
888665555 James Borg M 1
3. Select the groups that satisfy:
"having count(*) > 2
ssn fname lname sex dno
--------- ------ -------- --- -----------
123456789 John Smith M 5
333445555 Frankl Wong M 5
666884444 Ramesh Narayan M 5
987987987 Ahmad Jabbar M 4 (COUNT(*) <=2)
888665555 James Borg M 1 (COUNT(*) <=2)
4. The SELECT expression are computed:
SELECT dno, sum(salary)
Result:
dno sum(salary)
----------- -------------------------------
5 108900.00
|