|
select ssn, dno, salary from employee; +-----------+-----+----------+ | ssn | dno | salary | +-----------+-----+----------+ | 123456789 | 5 | 20000.00 | | 333445555 | 5 | 40000.00 | | 666884444 | 5 | 38000.00 | | 453453453 | 5 | 25000.00 | | 999887777 | 4 | 25000.00 | | 987654321 | 4 | 43000.00 | | 987987987 | 4 | 25000.00 | | 888665555 | 1 | 55000.00 | +-----------+-----+----------+ Group by dno and perform set function on each group !! |
|
We need employee's information: ssn dno salary --------- ----------- --------- 123456789 5 20000.00 333445555 5 40000.00 666884444 5 38000.00 453453453 5 25000.00 999887777 4 25000.00 987654321 4 43000.00 987987987 4 25000.00 888665555 1 55000.00 |
(Note: some database systems - like MySQL - will not report the grouping attribute error)
|
We need to use the works_on information: essn pno hours --------- ----------- ------- 123456789 1 32.5 123456789 2 7.5 333445555 2 10.0 333445555 3 10.0 333445555 10 10.0 333445555 20 10.0 999887777 30 30.0 999887777 10 10.0 987654321 30 20.0 987654321 20 15.0 666884444 3 40.0 453453453 1 20.0 453453453 2 20.0 987987987 30 5.0 987987987 10 35.0 888665555 20 1.0 |