|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Query Problems
Hi
The following queries are running, but I think something is missing. Write a command file to display the department number (deptno), location (loc) and the number of clerks for each department in the database. SELECT d.deptno.d.dname,d.loc FROM emp e, dept d WHERE d.deptno = e.deptno AND e.job = 'CLERK' The above query works fine, but should there not be a COUNT function in the query as the question above asks to display the numbers of clerks in each dept in the database. Also the following query: Write a command file to update the commission (comm) of the salesmen by 1.5% of the income from all the sales they have been associated with. UPDATE emp e SET comm = (SELECT SUM(NVL(comm,0))*0.015 FROM emp e WHERE e.empno = e.empno GROUP BY e.empno This is not running and is coming up with an invalid trigger error. Would I need to use a CREATE table command first and then try to update it, would that be why it isnt working? Please help. |
|
#2
|
|||
|
|||
|
Write a command file to display the department number (deptno), location (loc) and the number of clerks for each department in the database.
SELECT d.deptno, d.dname, d.loc FROM dept d, (SELECT deptno, count(*) FROM emp WHERE job = 'CLERK' GROUP BY deptno) e WHERE d.deptno = e.deptno / |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Query Problems |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|